Copy codeThe Code is as follows:
/**
* Determine whether it is a search engine spider
*
* @ 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 )",
"Baidusp ",
"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;
}
}