判断访问者是否为搜索引擎蜘蛛

Posted 阿诺实验室

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了判断访问者是否为搜索引擎蜘蛛相关的知识,希望对你有一定的参考价值。

/**
*    判断是否为搜索引擎蜘蛛
*
*    @author    Eddy
*    @return    bool
*/
function isCrawler() {
        $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判断来访者是否是搜索引擎的蜘蛛

Python Django Middleware中间件限制IP访问频率及判断搜索引擎爬虫

爬虫日记(85):Scrapy的ExecutionEngine类

网站程序怎么判断是访客还是蜘蛛在访问?

判断百度蜘蛛偷偷进行转移权重301,给新站提权

判断来防ip是否为蜘蛛