zoukankan      html  css  js  c++  java
  • 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')."	".$_SERVER["REMOTE_ADDR"]."	".$bot."	".'http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]."
    ");
    23     fclose($fp);
    24 }
  • 相关阅读:
    斐波那契数列
    进制转换为伪代码
    python模拟进程
    第十一周学习总结
    第十周学习总结
    第九周学习总结
    俄罗斯方块
    熟悉编程语言
    小学四则运算
    第八周学习总结
  • 原文地址:https://www.cnblogs.com/liangle/p/3171821.html
Copyright © 2011-2022 走看看