关于如何判断是不是百度或者其它搜索引擎蜘蛛的php代码
2013-03-01 16:22
519 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>无标题文档</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <link rel="stylesheet" type="text/css" href="/c3.css" /> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <meta http-equiv="Content-Language" content="zh-cn" /> <meta name="robots" content="all" /> <meta name="author" content="lunanzuche.com" /> <meta name="Copyright" content="Copyright www.lunanzuche.com All Rights Reserved." /> <meta name="MSSmartTagsPreventParsing" content="true" /> <meta http-equiv="imagetoolbar" content="false" /> </head> <body> <?PHP /** * 判断是否为搜索引擎蜘蛛 * * @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)", "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; } } ?> </body> </html>
以上主要就是根据函数进行判断
相关文章推荐
- [JS代码]如何判断ipad或者iphone是否为横屏或者竖屏 - portrait或者landscape
- PHP判断搜索引擎蜘蛛并自动记忆到文件的代码
- PHP判断来访是搜索引擎蜘蛛还是普通用户的代码小结
- php 关于如何获取域名或者IP地址的$_SERVER['']
- php 判断访客是否为搜索引擎蜘蛛的函数代码
- 关于如何在html文件中使用php代码
- PHP判断来访是搜索引擎蜘蛛还是普通用户的代码小结
- PHP如何判断一个数组是一维数组或者是二维数组?用什么函数?
- PHP判断搜索引擎蜘蛛并自动记忆到文件的代码
- [JS代码]如何判断ipad或者iphone是否为横屏或者竖屏 - portrait或者landscape
- [php] php如何判断是不是ajax提交
- 关于PHP如何用代码删除Runtime下的文件,做到物理删除缓存
- [JS代码]如何判断ipad或者iphone是否为横屏或者竖屏 - portrait或者lan...
- PHP判断来访是搜索引擎蜘蛛还是普通用户的代码小结
- 关于如何判断网页是静态还是伪静态的方法——本文来自雅致生活网『www.yzsh0514.com』原帖地址:http://www.yzsh0514.com/bbs/viewthread.php?tid==0
- 如何使用PHP或者js判断当前是微信浏览器访问
- [JS代码]如何判断ipad或者iphone是否为横屏或者竖屏 - portrait或者landscape
- php如何判断一个字符串是不是base64编码
- 利用百度site app代码判断访问者平台