PHP 进行蜘蛛访问日志统计

PHP 进行蜘蛛访问日志统计1$useragent=addslashes(strtolower($_SERVER[‘HTTP_USER_AGENT’]));23if(strpos($useragent,’googlebot’)!==false){$bot=’Google’;}4elseif(strpos($useragent,’mediapartners-google’)!=…

PHP 进行蜘蛛访问日志统计

 1 $useragent = addslashes(strtolower($_SERVER['HTTP_USER_AGENT']));
 2 
 3 if (strpos($useragent, 'googlebot')!== false){
   
   $bot = 'Google';}
 4 elseif (strpos($useragent,'mediapartners-google') !== false){
   
   $bot = 'Google Adsense';}
 5 elseif (strpos($useragent,'baiduspider') !== false){
   
   $bot = 'Baidu';}
 6 elseif (strpos($useragent,'sogou spider') !== false){
   
   $bot = 'Sogou';}
 7 elseif (strpos($useragent,'sogou web') !== false){
   
   $bot = 'Sogou web';}
 8 elseif (strpos($useragent,'sosospider') !== false){
   
   $bot = 'SOSO';}
 9 elseif (strpos($useragent,'360spider') !== false){
   
   $bot = '360Spider';}
10 elseif (strpos($useragent,'yahoo') !== false){
   
   $bot = 'Yahoo';}
11 elseif (strpos($useragent,'msn') !== false){
   
   $bot = 'MSN';}
12 elseif (strpos($useragent,'msnbot') !== false){
   
   $bot = 'msnbot';}
13 elseif (strpos($useragent,'sohu') !== false){
   
   $bot = 'Sohu';}
14 elseif (strpos($useragent,'yodaoBot') !== false){
   
   $bot = 'Yodao';}
15 elseif (strpos($useragent,'twiceler') !== false){
   
   $bot = 'Twiceler';}
16 elseif (strpos($useragent,'ia_archiver') !== false){
   
   $bot = 'Alexa_';}
17 elseif (strpos($useragent,'iaarchiver') !== false){
   
   $bot = 'Alexa';}
18 elseif (strpos($useragent,'slurp') !== false){
   
   $bot = '雅虎';}
19 elseif (strpos($useragent,'bot') !== false){
   
   $bot = '其它蜘蛛';}
20 if(isset($bot)){
21     $fp = @fopen('bot.txt','a');
22     fwrite($fp,date('Y-m-d H:i:s')."\t".$_SERVER["REMOTE_ADDR"]."\t".$bot."\t".'http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]."\r\n");
23     fclose($fp);
24 }

 

转载于:https://www.cnblogs.com/liangle/p/3171821.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/34237.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注