Home  >  Article  >  Backend Development  >  PHP uses curl to create a simple Baidu search

PHP uses curl to create a simple Baidu search

高洛峰
高洛峰Original
2016-12-23 15:36:511347browse

In the past few days, I have studied the curl library in php and made a simple Baidu search. First, enter the code

PHP uses curl to create a simple Baidu search
(.*?)<\/a><\/h3>/s'; preg_match_all($pre,$data,$match); foreach ($match[1] as $k => $v) { ?>

After analyzing the URLs in Baidu searches, I found a pattern

https://www.baidu. com/s?wd=Search keyword

But I found that after using the https protocol, I could not obtain the data on Baidu, so I changed it to http://www.baidu.com?wd=Search keyword!!

The rendering is as follows:

PHP uses curl to create a simple Baidu search

The above is the entire content of this article. I hope it will be helpful to everyone’s learning, and I also hope that everyone will visit the PHP Chinese website.

For more articles related to PHP using curl to create a simple Baidu search, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn