• 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 }
  • 相关阅读:
    点击图片跳转详情
    offsetwidth/clientwidth的区别
    css中让元素隐藏的多种方法
    js中的||、&&与!用法
    怎么区分静态网页和动态网页
    我的第一篇博客--新手勿喷
    2015腾讯暑期实习生面试
    ring0 与 ring3 层之间的交互
    驱动层得到进程的完整路径
    WinDbg调试流程的学习及对TP反调试的探索
  • 原文地址:https://www.cnblogs.com/liangle/p/3171821.html
Copyright © 2020-2023  润新知