通过PHP程序知道蜘蛛是否访问你的网站(附代码)

搜索引擎的蜘蛛访问网站是通过远程抓取页面来进行的,我们不能使用JS代码来取得蜘蛛的Agent信息,但是我们可以通过image标签,这样我们就可以得到蜘蛛的agent资料了,通过对agent资料的分析,就可以确定蜘蛛的种类、性别等因素,我们在通过数据库或者文本来记录就可以进行统计了。

数据库结构:

  1. # 表的结构 `naps_stats_bot` 
  2.  
  3. CREATE TABLE `naps_stats_bot` ( 
  4. `botid` int(10) unsigned NOT NULL auto_increment, 
  5. `botname` varchar(100) NOT NULL default ''
  6. `botagent` varchar(200) NOT NULL default ''
  7. `bottag` varchar(100) NOT NULL default ''
  8. `botcount` int(11) NOT NULL default '0'
  9. `botlast` datetime NOT NULL default '0000-00-00 00:00:00'
  10. `botlasturl` varchar(250) NOT NULL default ''
  11. UNIQUE KEY `botid` (`botid`), 
  12. KEY `botname` (`botname`) 
  13. ) TYPE=MyISAM AUTO_INCREMENT=9 ; 
  14.  
  15. # 导出表中的数据 `naps_stats_bot` 
  16.  
  17. INSERT INTO `naps_stats_bot` VALUES (1, 'Googlebot''Googlebot/2.X ( http://www.googlebot.com/bot.html)''googlebot', 0, '0000-00-00 00:00:00'''); 
  18. INSERT INTO `naps_stats_bot` VALUES (2, 'MSNbot''MSNBOT/0.1 (http://search.msn.com/msnbot.htm)''msnbot', 0, '0000-00-00 00:00:00'''); 
  19. INSERT INTO `naps_stats_bot` VALUES (3, 'Inktomi Slurp''Slurp/2.0''slurp', 0, '0000-00-00 00:00:00'''); 
  20. INSERT INTO `naps_stats_bot` VALUES (4, 'Baiduspider''Baiduspider ( http://www.baidu.com/search/spider.htm)''baiduspider', 0, '0000-00-00 00:00:00'''); 
  21. INSERT INTO `naps_stats_bot` VALUES (5, 'Yahoobot''Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)''slurp', 0, '0000-00-00 00:00:00'''); 
  22. INSERT INTO `naps_stats_bot` VALUES (6, 'Sohubot''sohu-search''sohu-search', 0, '0000-00-00 00:00:00'''); 
  23. INSERT INTO `naps_stats_bot` VALUES (7, 'Lycos''Lycos/x.x''lycos', 0, '0000-00-00 00:00:00'''); 
  24. INSERT INTO `naps_stats_bot` VALUES (8, 'Robozilla''Robozilla/1.0''robozilla', 0, '0000-00-00 00:00:00'''); 

PHP程序:

  1. error_reporting(E_ALL & ~E_NOTICE); 
  2.  
  3. function get_naps_bot() 
  4. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); 
  5.  
  6. if (strpos($useragent'googlebot') !== false){ 
  7. return 'Googlebot'
  8.  
  9. if (strpos($useragent'msnbot') !== false){ 
  10. return 'MSNbot'
  11.  
  12. if (strpos($useragent'slurp') !== false){ 
  13. return 'Yahoobot'
  14.  
  15. if (strpos($useragent'baiduspider') !== false){ 
  16. return 'Baiduspider'
  17.  
  18. if (strpos($useragent'sohu-search') !== false){ 
  19. return 'Sohubot'
  20.  
  21. if (strpos($useragent'lycos') !== false){ 
  22. return 'Lycos'
  23.  
  24. if (strpos($useragent'robozilla') !== false){ 
  25. return 'Robozilla'
  26. return false; 
  27. $tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']); 
  28. //添加蜘蛛的抓取记录 
  29. $searchbot = get_naps_bot(); 
  30. if ($searchbot) { 
  31. $DB_naps->query("UPDATE naps_stats_bot SET botcount=botcount 1, botlast=NOW(), botlasturl='$tlc_thispage' WHERE botname='$searchbot'"); 
  32. ?> 
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » 通过PHP程序知道蜘蛛是否访问你的网站(附代码)

43 评论

  1. buy levofloxacin without prescription cost levaquin

  2. prednisone uk tadalafil drug brand sildenafil 100mg

  3. buy baclofen generic toradol 10mg pill buy toradol 10mg online cheap

  4. ceftin 250mg drug robaxin 500mg uk purchase methocarbamol sale

  5. sildenafil 100mg pills for sale cialis pills 20mg order tadalafil 20mg generic

  6. terbinafine 250mg pill suprax price amoxicillin drug

  7. online blackjack for real money rivers casino free roulette

  8. pay for a research paper arava for sale purchase azulfidine online

  9. doxycycline 100mg drug buy aralen pills buy methylprednisolone 16 mg online

  10. provigil 200mg cheap buy phenergan phenergan buy online

  11. sildenafil buy online buy lyrica online order finasteride 5mg online

  12. ondansetron 8mg pills oral zofran 4mg purchase bactrim generic

发表评论

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡