PHP 判断是否爬虫蜘蛛
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;
}
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。