There are many functions that can collect remote pages in PHP, such as file_get_contents (), fopen,file () These functions can collect remote server data, but to calculate performance curl most, he supports multithreading.
Cases
TD bgcolor= "#FFE7CE" height= "width=" 464 "> code as follows
copy code |
$curlPost = ' a=1&b=2 ';//analog post data $ch = Curl_ Init (); curl_setopt ($ch, Curlopt_httpheader, Array (' x-forwarded-for:0.0.0.0 ', ' client-ip:0.0.0.0 '));//Construction IP Curl_ Setopt ($ch, Curlopt_referer, "http://www.bkjia.com/"); Construct the route curl_setopt ($ch, Curlopt_url, ' http://www.bkjia.com ');//page path to crawl curl_setopt ($ch, Curlopt_ Returntransfer, 1); curl_setopt ($ch, Curlopt_timeout, 30); curl_setopt ($ch, Curlopt_postfields, $curlPost);//post value $file _contents = curl_exec ($ch);//The contents of the crawl are placed in the variable curl_close ($ch) |
Another option is to use the file_get_contents () remote file fetch function to get the remote page content
Precautions
Curl () is highly efficient and supports multi-threading, but needs to turn on the next Curl extension. Here are the steps the Curl extension opens:
1, the PHP folder under the three files Php_curl.dll,libeay32.dll,ssleay32.dll copied to System32;
2, the php.ini (c:windows directory) in the; Extension=php_curl.dll in the semicolon removed;
3. Restart Apache or IIS.
http://www.bkjia.com/PHPjc/445611.html www.bkjia.com true http://www.bkjia.com/PHPjc/445611.html techarticle There are many functions that can collect remote pages in PHP, such as file_get_contents (), fopen,file () These functions can collect remote server data, but to calculate the performance curl most can, he supports ...