加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP记录搜索引擎蜘蛛访问网站足迹的方法

发布时间:2020-12-12 20:50:06 所属栏目:PHP教程 来源:网络整理
导读:本篇章节讲解PHP记录搜索引擎蜘蛛访问网站足迹的方法。供大家参考研究。具体分析如下: 搜索引擎的蜘蛛访问网站是通过远程抓取页面来进行的,我们不能使用JS代码来取得蜘蛛的Agent信息,但是我们可以通过image标签,这样我们就可以得到蜘蛛的agent资

本篇章节讲解PHP记录搜索引擎蜘蛛访问网站足迹的方法。分享给大家供大家参考。具体分析如下:

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

数据库结构:

以下为引用的内容:

CREATE TABLE naps_stats_bot (
botid int(10) unsigned NOT NULL auto_increment,botname varchar(100) NOT NULL default '',botagent varchar(200) NOT NULL default '',bottag varchar(100) NOT NULL default '',botcount int(11) NOT NULL default '0',botlast datetime NOT NULL default '0000-00-00 00:00:00',botlasturl varchar(250) NOT NULL default '',UNIQUE KEY botid (botid),KEY botname (botname)
) TYPE=MyISAM AUTO_INCREMENT=9 ;

导出表中的数据 naps_stats_bot

INSERT INTO naps_stats_bot VALUES (1,'Googlebot','Googlebot/2.X (+http://www.googlebot.com/bot.html)','googlebot','0000-00-00 00:00:00','');
INSERT INTO naps_stats_bot VALUES (2,'MSNbot','MSNBOT/0.1 (http://search.msn.com/msnbot.htm)','msnbot','');
INSERT INTO naps_stats_bot VALUES (3,'Inktomi Slurp','Slurp/2.0','slurp','');
INSERT INTO naps_stats_bot VALUES (4,'Baiduspider','Baiduspider+(+http://www.baidu.com/search/spider.htm)','baiduspider','');
INSERT INTO naps_stats_bot VALUES (5,'Yahoobot','Mozilla/5.0+(compatible;+Yahoo!+Slurp;+http://help.yahoo.com/help/us/ysearch/slurp)','');
INSERT INTO naps_stats_bot VALUES (6,'Sohubot','sohu-search','');
INSERT INTO naps_stats_bot VALUES (7,'Lycos','Lycos/x.x','lycos','');
INSERT INTO naps_stats_bot VALUES (8,'Robozilla','Robozilla/1.0','robozilla','');

PHP程序如下:

以下为引用的内容:

query("UPDATE naps_stats_bot SET botcount=botcount+1,botlast=NOW(),botlasturl='$tlc_thispage' WHERE botname='$searchbot'"); } ?>

希望本文所述对大家的php程序设计有所帮助。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读