日韩熟女精品日韩网站-久久久久久久久天天-美女18禁久久精品-av在线一区二区免费播放

中山php|最優(yōu)網(wǎng)絡中山做網(wǎng)站 中山php建站

最優(yōu)良人

2011/08/08 at 09:08

模仿蜘蛛抓取網(wǎng)站內(nèi)容

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換成可以寫要抓的頁面就可以了

-