function isCrawler() {    
     if(ini_get('browscap')) {    
         $browser= get_browser(NULL, true);    
         if($browser['crawler']) {    
             return true;    
         }    
     } else if (isset($_SERVER['HTTP_USER_AGENT'])){    
         $agent= $_SERVER['HTTP_USER_AGENT'];    
         $crawlers= array(    
             "/Googlebot/",    
             "/Yahoo! Slurp;/",    
             "/msnbot/",    
             "/Mediapartners-Google/",    
             "/Scooter/",    
             "/Yahoo-MMCrawler/",    
             "/FAST-WebCrawler/",    
             "/Yahoo-MMCrawler/",    
             "/Yahoo! Slurp/",    
             "/FAST-WebCrawler/",    
             "/FAST Enterprise Crawler/",    
             "/grub-client-/",    
             "/MSIECrawler/",    
             "/NPBot/",    
             "/NameProtect/i",    
             "/ZyBorg/i",    
             "/worio bot heritrix/i",    
             "/Ask Jeeves/",    
             "/libwww-perl/i",    
             "/Gigabot/i",    
             "/bot@bot.bot/i",    
             "/SeznamBot/i",    
         );    
         foreach($crawlers as $c) {    
             if(preg_match($c, $agent)) {    
                 return true;    
             }    
         }    
     }    
     return false;    
}

源地址:https://cyhour.com/875/