国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > PHP > 正文

通過(guò)PHP程序知道蜘蛛是否訪(fǎng)問(wèn)你的網(wǎng)站(附代碼)

2024-05-04 21:56:47
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

搜索引擎的蜘蛛訪(fǎng)問(wèn)網(wǎng)站是通過(guò)遠(yuǎn)程抓取頁(yè)面來(lái)進(jìn)行的,我們不能使用JS代碼來(lái)取得蜘蛛的Agent信息,但是我們可以通過(guò)image標(biāo)簽,這樣我們就可以得到蜘蛛的agent資料了,通過(guò)對(duì)agent資料的分析,就可以確定蜘蛛的種類(lèi)、性別等因素,我們?cè)谕ㄟ^(guò)數(shù)據(jù)庫(kù)或者文本來(lái)記錄就可以進(jìn)行統(tǒng)計(jì)了。

數(shù)據(jù)庫(kù)結(jié)構(gòu):

  1. # 表的結(jié)構(gòu) `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. # 導(dǎo)出表中的數(shù)據(jù) `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. ?> 

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 阳东县| 阿坝县| 双辽市| 大冶市| 铜川市| 永川市| 民和| 清丰县| 聂荣县| 陆川县| 奉化市| 鹤岗市| 武平县| 乌恰县| 柳江县| 铜川市| 上杭县| 砚山县| 石景山区| 哈巴河县| 普宁市| 靖远县| 三穗县| 东乌| 古田县| 弥渡县| 卢湾区| 随州市| 伊通| 钟祥市| 四川省| 邵阳县| 凌海市| 内乡县| 施甸县| 灵川县| 四川省| 儋州市| 淳安县| 通海县| 诸城市|