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

首頁 > 開發 > PHP > 正文

PHP記錄搜索引擎蜘蛛訪問網站足跡的方法

2024-05-04 23:34:17
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了PHP記錄搜索引擎蜘蛛訪問網站足跡的方法,實例分析了針對php記錄搜索引擎蜘蛛訪問足跡的技巧,涉及數據庫的創建及php記錄各類常見搜索引擎訪問的方法,需要的朋友可以參考下

本文實例講述了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. # 導出表中的數據 `naps_stats_bot` 
  15. 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'''); 
  16. 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'''); 
  17. INSERT INTO `naps_stats_bot` VALUES (3, 'Inktomi Slurp''Slurp/2.0''slurp', 0, '0000-00-00 00:00:00'''); 
  18. INSERT INTO `naps_stats_bot` VALUES (4, 'Baiduspider''Baiduspider+(+http://www.baidu.com/search/spider.htm)''baiduspider', 0, '0000-00-00 00:00:00'''); 
  19. 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'''); 
  20. INSERT INTO `naps_stats_bot` VALUES (6, 'Sohubot''sohu-search''sohu-search', 0, '0000-00-00 00:00:00'''); 
  21. INSERT INTO `naps_stats_bot` VALUES (7, 'Lycos''Lycos/x.x''lycos', 0, '0000-00-00 00:00:00'''); 
  22. INSERT INTO `naps_stats_bot` VALUES (8, 'Robozilla''Robozilla/1.0''robozilla', 0, '0000-00-00 00:00:00'''); 

PHP程序如下:

以下為引用的內容:

 

 
  1. <?php 
  2. /************************ 
  3. * NAPS -- Network Article Publish System 
  4. * ---------------------------------------------- 
  5. * bot.php 
  6. * ------------------- 
  7. * begin : 2004-08-15 
  8. * 
  9. ************************/ 
  10. /************************ 
  11. * 
  12. * This program is free software; you can redistribute it and/or modify 
  13. * it under the terms of the GNU General Public License as published by 
  14. * the Free Software Foundation; either version 2 of the License. 
  15. * 
  16. ************************/ 
  17. /************************ 
  18. * 
  19. * NAPS產品是自由軟件。你可以且必須根據《GNU GPL-GNU通用公共許可證》的相關規定 
  20. * 復制、修改及分發NAPS產品。任何以NAPS產品為基礎的衍生發行版未必須經過飄飄的授權。 
  21. * 
  22. ************************/ 
  23. error_reporting(E_ALL & ~E_NOTICE); 
  24. function get_naps_bot() 
  25. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); 
  26. if (strpos($useragent'googlebot') !== false){ 
  27. return 'Googlebot'
  28. if (strpos($useragent'msnbot') !== false){ 
  29. return 'MSNbot'
  30. if (strpos($useragent'slurp') !== false){ 
  31. return 'Yahoobot'
  32. if (strpos($useragent'baiduspider') !== false){ 
  33. return 'Baiduspider'
  34. if (strpos($useragent'sohu-search') !== false){ 
  35. return 'Sohubot'
  36. if (strpos($useragent'lycos') !== false){ 
  37. return 'Lycos'
  38. if (strpos($useragent'robozilla') !== false){ 
  39. return 'Robozilla'
  40. }  
  41. return false; 
  42. $tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']); 
  43. //添加蜘蛛的抓取記錄 
  44. $searchbot = get_naps_bot(); 
  45. if ($searchbot) { 
  46. $DB_naps->query("UPDATE naps_stats_bot SET botcount=botcount+1, botlast=NOW(), botlasturl='$tlc_thispage' WHERE botname='$searchbot'"); 
  47. ?> 

希望本文所述對大家的php程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 陆良县| 邵东县| 广南县| 邳州市| 三江| 新蔡县| 保定市| 渝北区| 泸州市| 治多县| 汝南县| 宁武县| 乌苏市| 郁南县| 屏南县| 金平| 高清| 阿克| 兴城市| 旬阳县| 响水县| 凯里市| 大同县| 信阳市| 台江县| 安阳市| 永城市| 密山市| 射阳县| 宁蒗| 沙河市| 肥西县| 齐齐哈尔市| 土默特右旗| 芒康县| 绥阳县| 眉山市| 龙井市| 横峰县| 会昌县| 哈巴河县|