首页 > 后端开发 > php教程 > php判断访问者是搜索引擎还是真实用户的代码

php判断访问者是搜索引擎还是真实用户的代码

WBOY
发布: 2016-07-25 09:00:03
原创
1660 人浏览过
  1. /**
  2. * 判断访问来源 搜索引擎还是真实用户
  3. * site bbs.it-home.org
  4. */
  5. function is_bot()
  6. {
  7. /* This function will check whether the visitor is a search engine robot */
  8. //根据需要扩充此数组
  9. $botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi",
  10. "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory",
  11. "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
  12. "crawler", "bbs.it-home.org", "Googlebot", "Scooter", "Slurp",
  13. "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
  14. "Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
  15. "Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot",
  16. "Butterfly","Twitturls","Me.dium","Twiceler");
  17. foreach($botlist as $bot)
  18. {
  19. if(strpos($_SERVER['HTTP_USER_AGENT'],$bot)!==false)
  20. return true; // Is a bot
  21. }
  22. return false; // Not a bot
  23. }
  24. ?>
复制代码


来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板