1.使用Snoopy或curl传搜索引擎爬虫的USERAGENT值。
查看搜索引擎爬虫的USERAGENT值:http://www.cnblogs.com/grimm/p/5068092.html (http://www.geekso.com/spdier-useragent/ )
2.使用Snoopy或curl传referer值。
如:$snoopy->referer = 'http://www.google.com';
$header[] = "Referer: http://www.google.com/";
3.使用Snoopy或curl代理。
如:$snoopy->proxy_host = "59.108.44.41"; $
snoopy->proxy_port = "3128";
4.使用Snoopy或curl防造IP。
如:$snoopy->rawheaders['X_FORWARDED_FOR'] = '127.0.0.1';
$snoopy->rawheaders['CLIENT-IP'] = '127.0.0.1';
5.用php写一个重起路由器的程序,这样就会获得新的ip地址。
6.如果发现重起路由器还是显示被封,有可能对方封了你路由器的mac地址,现在路由器都有修改MAC的功能,可以写程序或手动修改路由器的MAC地址。
例如:
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)