function baiduSpider($url){
$ch = curl_init();
$user_agent = "Baiduspider+(+http://www.baidu.com/search/spider.htm)";//这里模拟的是百度蜘蛛
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $url);//这里写一个来源地址,可以写要抓的页面的首页
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
$temp=curl_exec($ch);
return $temp;
}
php必须开启curl扩展,把$url换成可以写要抓的页面就可以了
中山php|最优网络 :中山做网站 中山php建站
最优良人
2011/08/08 at 09:08