Reptiles must be well understood by the script to crawl the target file.
I'd like to get a daily vegetable price.
To view the console, if there is information about the interface naturally convenient, but directly request the interface to obtain data.
Filtering filtering is required for page information.
The information in the graph is very regular and easy to filter.
First get the entire page, you can use Curl to request the page address, curl is also easy to need to verify the information of the page pass parameters.
Filter page data can be replaced with regular expression matching.
<?PHPHeader("content-type:text/html; Charset=utf-8 " ); $ch=Curl_init (); $url= "Http://www.xinfadi.com.cn/marketanalysis/0/list/1.shtml"; curl_setopt ($ch, Curlopt_useragent, "mozilla/5.0 (Windows NT 10.0; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/68.0.3440.75 safari/537.36 " ); curl_setopt ($ch, Curlopt_url,$url); curl_setopt ($ch, Curlopt_returntransfer, 1); $content=curl_exec ($ch); Preg_match_all("/<td style=\" text-align:left;padding-left:5px;\ "> (. *?) <\/td><td> (. *?) <\/td><td> (. *?) <\/td><td> (. *?) <\/td><td> (. *?) <\/td><td> (. *?) <\/td><td> (. *?) <\/td>/",$content,$matchs,Preg_set_order); Print_r($matchs);
This is done, the main is to use regular expressions to filter the page, crawling image is the same.
PHP page Crawler