Sample code for using curl to grab remote page content_PHP tutorial

WBOY
Release: 2016-07-21 14:59:44
Original
673 people have browsed it

The most basic operation is as follows

Copy the code The code is as follows:

$curlPost = 'a=1&b =2';//Simulated POST data
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:0.0.0.0', 'CLIENT-IP:0.0. 0.0')); //Construct IP
curl_setopt($ch, CURLOPT_REFERER, "http://www.jb51.net/"); //Construct source
curl_setopt($ch, CURLOPT_URL, 'http ://www.jb51.net');//Page path to be crawled
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 captured content is placed in the variable
curl_close($ch)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328109.htmlTechArticleThe most basic operation is as follows. Copy the code as follows: $curlPost = 'a=1//Simulate POST data $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:0.0.0.0', 'CLI...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!