PHP判断访问者是否为搜索引擎蜘蛛的函数代码

星期日 上午 09:15 狂奔的蜗牛 PHP开发 5949 views
0
Comments
/** 
* 判断是否为搜索引擎蜘蛛 
* 
* @author Crazy Snail
* @return bool 
*/ 
function is_crawler() { 
    $agent= strtolower($_SERVER['HTTP_USER_AGENT']); 
    if (!empty($agent)) { 
    $spiderSite= array( 
    "TencentTraveler", 
    "Baiduspider+", 
    "BaiduGame", 
    "Googlebot", 
    "msnbot", 
    "Sosospider+", 
    "Sogou web spider", 
    "ia_archiver", 
    "Yahoo! Slurp", 
    "YoudaoBot", 
    "Yahoo Slurp", 
    "MSNBot", 
    "Java (Often spam bot)", 
    "BaiDuSpider", 
    "Voila", 
    "Yandex bot", 
    "BSpider", 
    "twiceler", 
    "Sogou Spider", 
    "Speedy Spider", 
    "Google AdSense", 
    "Heritrix", 
    "Python-urllib", 
    "Alexa (IA Archiver)", 
    "Ask", 
    "Exabot", 
    "Custo", 
    "OutfoxBot/YodaoBot", 
    "yacy", 
    "SurveyBot", 
    "legs", 
    "lwp-trivial", 
    "Nutch", 
    "StackRambler", 
    "The web archive (IA Archiver)", 
    "Perl tool", 
    "MJ12bot", 
    "Netcraft", 
    "MSIECrawler", 
    "WGet tools", 
    "larbin", 
    "Fish search", 
    ); 
    foreach($spiderSite as $val) { 
        $str = strtolower($val); 
        if (strpos($agent, $str) !== false) { 
        return true; 
        } 
      } 
    } else { 
    return false; 
    } 
} 
PHP判断蜘蛛 2012/03/24 09:15:09
评论(0)
没有评论!

发表评论

引用成功取消引用×

昵称*: 邮箱*: 网址:

最多可输入300字符 验证码*:


Process: 0.056s | DB :17 queries | UseMem:2,286 kb