PHP完全自学手册(珍藏版) 中文pdf扫描版下载
php curl伪装抓取
$ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0 ); // 过滤HTTP头 curl_setopt($ch, CURLOPT_TIMEOUT, 40); curl_setopt($ch, CURLOPT_USERAGENT, 'Baiduspider+(+http://www.baidu.com/search/spider.htm)'); $ip = '220.181.7.121'; curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:' . $ip, 'CLIENT-IP:' . $ip)); curl_setopt($ch, CURLOPT_REFERER, "http://www.baidu.com/search/spider.html"); curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果 $responseText = curl_exec($ch); curl_close($ch);
转载请注明:谷谷点程序 » php curl 抓取数据伪装