日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > 通過PHP程序知道蜘蛛是否訪問你的網站(附代碼)

通過PHP程序知道蜘蛛是否訪問你的網站(附代碼)

來源:程序員人生   發布時間:2014-06-13 06:42:43 閱讀次數:2424次

搜索引擎的蜘蛛訪問網站是通過遠程抓取頁面來進行的,我們不能使用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. ?> 
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 日韩免费久久 | 国产视频福利在线 | 精品一区二区久久久久久久网站 | 成人区精品一区二区婷婷 | 亚洲免费黄色 | 最近中文字幕mv在线资源 | 国产精品视频不卡 | 国产精品久久久久久久久久免 | 日韩激情精品一区二区三区 | 秋霞电影网在线 | 国产精品欧美久久 | 日韩精品小视频 | 日韩专区在线播放 | 午夜精品一区 | 91精品国产欧美一区二区成人 | 久久午夜精品 | 久热中文| 一区二视频 | 国产精品正在播放 | 最新中文字幕第一页 | 99精品视频在线观看免费 | 日本不卡在线播放 | 中文字幕亚洲色图 | 少妇精品视频 | 乱码一区 | 福利精品 | 欧美一区二区三区在线看 | 亚洲欧美自拍视频 | 99re视频| 亚洲精品欧美一区二区三区 | 一本到高清 | 视频在线精品 | а_天堂中文最新版地址 | 男女午夜视频 | 成年人免费网站 | 欧美国产日韩在线观看 | 精品成人在线视频 | 成人久久久久 | 一区二区三区中文 | 亚洲精品一区二区三 | 欧美xxxhd|