获取搜索引擎访问的方法无非是服务器日志和程序的判断,查看日志分析日志属于运维比较高深的东西了,只会看不会分析了。现在用php程序实现下,以后可以根据特殊需求去做一些事情了。
$agent = strtolower($_SERVER["HTTP_USER_AGENT"]); //检查浏览页面的访问者在用什么浏览器 $bot_string = array( \'googlebot\' => \'GoogleBot\', \'baiduspider\' => \'BaiduSpider\', \'mediapartners-google\' => \'GoogleAdsense\', \'sosospider\' => \'SosoSpider\', \'sogou web spider\' => \'SogouSpider\', \'sogou push spider\' => \'SogouSpider\', \'yahoo! slurp\' =>\'Yahoo Slurp\', \'msnbot\' =>\'msnbot\', \'iaskspider\' => \'ISAK\', \'youdaoBot\' => \'YoudaoBot\', \'ahrefsBot\' => \'AhrefsBot\', \'jikespider\' => \'JikeSpider\', \'360spider\' => \'360Spider\', ); $isbot = 0; foreach ($bot_string as $key => $value){ if(strpos($agent, $key) !== false){ $isbot = 1; } } if($isbot ==true){ "想干的事情" }
以后如果再有增加的话,再往数组中添加即可了。经济适用,好用不贵。