±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

­º­¶  ¡E  j2h ½×¾Â ¡E µ{¦¡³]­p°Q½×     ¡E 

[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




  • ÃÙ§Uºô¯¸       

    ¼s§Q¤£°Ê²£-ªO¾ô¦b¦a¥Í®Ú³Ì¹ê¦b--·sªO¯S°Ï«ü¦W«×³Ì°ª¡B­È±o±z«H¿àªº¦n©Ð¥ò
    §¹¾ã©Ð°T¡A©Ð«Î¡B©±­±¼öªùºë¿ïª«¥ó¡A¼s§Q¤£°Ê²£ Àu½è¥ò¤¶¡A©Ð«Î¯²¸î¡B¶R½æ¸ê°T³z©ú¡A¥æ©ö¯u¦w¤ß¡I
    ¼s§Q¤£°Ê²£-·sªO¯S°Ï«ü¦W«×³Ì°ª¡B­È±o±z«H¿àªº¦n©Ð¥ò
    ±zªº¦«¥I,¼s§Q¥Î¤ß¬°±zªA°È



  • ¡@¦@ 0 ¤H¦^À³

    ©m¦W¡G
    §G§i¤º®e¡G
    ¨ä¥L¿ï¶µ: