±MÀç¦U¦¡©î°£¤uµ{¡G¼t©Ð©î°£¡B©Ð«Î©î°£ ¸ËæC©î°£¡B¾÷±ñ©î°£¤Î¼o¤ª÷¦^¦¬¶R½æ¡C | Àô«O§ëÃĵL¦¾¬V¡A±M·~§Þ³N¦³®Ä¹ï§Ü´o¤H¦Ñ¹« ¥þ±¦uÅ@±z¡I»ù®æ¤½¹D¹ê´f¡A½Ð³t¬¢¡I |
[php] php§P断来访ªÌ¬O§_¬O·j¯Á¤Þ� |
©ÐªF¡G©P¤p©j µoªí®É¶¡¡G2016-10-31 |
function is_crawler() { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $spiders = array( 'Googlebot', // Google ª¦¦ä 'Baiduspider', // ¦Ê«×ª¦¦ä 'Yahoo! Slurp', // ¶®ªêª¦¦ä 'YodaoBot', // ¦³¹Dª¦¦ä 'msnbot' // Bingª¦¦ä // §ó¦hª¦¦ä关键¦r ); foreach ($spiders as $spider) { $spider = strtolower($spider); if (strpos($userAgent, $spider) !== false) { return true; } } return false; } //该¥N码¤ù¬q来¦Û¤_: http://www.sharejs.com/codes/php/8945 ¤U±ªºphp¥N码ªþ带¤F§ó¦hªº»jµï标识 view sourceprint? 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 "§A¦n»jµïºë¡I"; } else{ echo "§A¤£¬O»jµïºë°Ú¡I"; } //该¥N码¤ù¬q来¦Û¤_: http://www.sharejs.com/codes/php/8945 |
|
©m¦W¡G | |||
§G§i¤º®e¡G | |||
¨ä¥L¿ï¶µ: | |||
|