In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to use PHP to judge whether a visit is a search engine spider or an ordinary user". In daily operation, it is believed that many people have doubts about how to use PHP to judge whether a visit is a search engine spider or an ordinary user. The editor consulted all kinds of materials and sorted out simple and useful operation methods. Hope to help you answer the question of "how to use PHP to judge whether a visit is a search engine spider or an ordinary user"! Next, please follow the editor to study!
1. A recommended method: php determines whether the search engine spider crawler or artificial access code, extracted from Discuz x3.2
In practical application, it can be judged that the operation is not performed by the search engine directly.
2. The second method:
Using PHP to realize Spider access Log Statistics
$useragent = addslashes (strtolower ($_ SERVER ['HTTP_USER_AGENT'])); if (strpos ($useragent,' googlebot')! = false) {$bot =' Google';} elseif (strpos ($useragent,'mediapartners-google')! = false) {$bot = 'Google Adsense';} elseif (strpos ($useragent,'baiduspider')! = false) {$bot =' Baidu';} elseif (strpos ($useragent,'sogou spider')! = false) {$bot = 'Sogou' } elseif (strpos ($useragent,'sogou web')! = = false) {$bot = 'Sogou web';} elseif (strpos ($useragent,'sosospider')! = = false) {$bot =' SOSO';} elseif (strpos ($useragent,'360spider')! = = false) {$bot = '360 spidery;} elseif (strpos ($useragent,'yahoo')! = false) {$bot =' Yahoo';} elseif (strpos ($useragent,'msn')! = false) {$bot = 'MSN' } elseif (strpos ($useragent,'msnbot')! = = false) {$bot = 'msnbot';} elseif (strpos ($useragent,'sohu')! = = false) {$bot =' Sohu';} elseif (strpos ($useragent,'yodaoBot')! = false) {$bot = 'Yodao';} elseif (strpos ($useragent,'twiceler')! = false) {$bot =' Twiceler';} elseif (strpos ($useragent,'ia_archiver')! = false) {$bot = 'Alexa_' } elseif (strpos ($useragent,'iaarchiver')! = = false) {$bot = 'Alexa';} elseif (strpos ($useragent,'slurp')! = = false) {$bot =' Yahoo';} elseif (strpos ($useragent,'bot')! = = false) {$bot = 'other spiders';} if (isset ($bot)) {$fp = @ fopen ('bot.txt','a') Fwrite ($fp,date ('Y-m-d SERVER ifp,date'). $_ SERVER ["REMOTE_ADDR"]. "\ t". $bot. "\ t". 'http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]."\r\n"); fclose ($fp);}
The third method:
We can use HTTP_USER_AGENT to determine whether it is a spider, search engine spiders have their own unique logo, some of which are listed below.
Function is_crawler () {$userAgent = strtolower ($_ SERVER ['HTTP_USER_AGENT']); $spiders = array (' Googlebot', / / Google crawler 'Baiduspider', / / Baidu crawler' Yahoo! Slurp', / / Yahoo crawler 'YodaoBot', / / youdao crawler' msnbot' / / Bing crawler / / more crawler keywords); foreach ($spiders as $spider) {$spider = strtolower ($spider); if (strpos ($userAgent, $spider)! = false) {return true;}} return false;}
The following php code comes with more spider logos
Function isCrawler () {echo $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;}} if (isCrawler ()) {echo "Hello Spider!" ;} else {echo "you are not a spider spirit!" ;}
The fourth method:
At this point, the study on "how to use PHP to judge whether a visit is a search engine spider or an ordinary user" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.