首页 » 交流学习 » PHP5 » 阅读文章

记录爬虫动作

2011-07-15 15:12 426 0 发表评论
标签:

$agent_meta=$_SERVER['HTTP_USER_AGENT'];
$agent=null;
if(stripos($agent_meta,’Googlebot’)!==false) {
    $agent=’Google’;
} elseif(stripos($agent_meta,’Baiduspider’)!==false) {
    $agent=’Baidu’;
} elseif(stripos($agent_meta,’Yahoo’)!==false) {
    $agent=’Yahoo’;
} elseif(stripos($agent_meta,’msnbot’)!==false) {
    $agent=’MSN’;
}
if($agent) {
    $access_url=Yii::app()->request->url;
    $access_time=time();
    Yii::app()->db->createCommand(‘INSERT INTO {{crawler}} (agent,agent_meta,access_url,access_time) VALUES (?,?,?,?)’)->execute(array($agent,$agent_meta,$access_url,$access_time));
}

评论 0条 (RSS 2.0) 发表

  1. 暂无评论,快抢沙发吧。

发表评论 (我不会回答任何技术性问题,如果你不会使用,请选择其他主题。)

  • 

联系我 Contact Me

回到页首