« 1 2345» Pages: ( 1/5 total )
本页主题: 用PHP程序统计蜘蛛是否访问你的网站 打印 | 加为IE收藏 | 复制链接 | 收藏主题 | 上一主题 | 下一主题

djks
问君能有几多愁, 恰是一江春水向东流。
级别: 五星会员

 用PHP程序统计蜘蛛是否访问你的网站

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

数据库结构:

Copy code
#
# 表的结构 `naps_stats_bot`
#

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




PHP程序:

Copy code
/***************************************************************************
* NAPS -- Network Article Publish System
* ----------------------------------------------
*                                bot.php
*                            -------------------
*  begin                : 2004-08-15
*  copyright            : (C) 2004 week9
*  email                : [email]wapshow@gmail.com[/email]
*  homepage            : [url]http://www.week9.com[/url]
*                          [url]http://www.wapshow.com[/url]
*
***************************************************************************/

/***************************************************************************
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License.
*
***************************************************************************/

/***************************************************************************
*
*  NAPS产品是自由软件。你可以且必须根据《GNU GPL-GNU通用公共许可证》的相关规定
*  复制、修改及分发NAPS产品。任何以NAPS产品为基础的衍生发行版未必须经过飘飘的授权。
*
***************************************************************************/

error_reporting(E_ALL & ~E_NOTICE);

function get_naps_bot()
{
        $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
                       
        if (strpos($useragent, 'googlebot') !== false){
                return 'Googlebot';
        }
       
        if (strpos($useragent, 'msnbot') !== false){
                return 'MSNbot';
        }
       
        if (strpos($useragent, 'slurp') !== false){
                return 'Yahoobot';
        }
       
        if (strpos($useragent, 'baiduspider') !== false){
                return 'Baiduspider';
        }
       
        if (strpos($useragent, 'sohu-search') !== false){
                return 'Sohubot';
        }
       
        if (strpos($useragent, 'lycos') !== false){
                return 'Lycos';
        }
       
        if (strpos($useragent, 'robozilla') !== false){
                return 'Robozilla';
        }       
        return false;
}

$tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']);
//添加蜘蛛的抓取记录
$searchbot = get_naps_bot();
if ($searchbot) {
        $DB_naps->query("UPDATE naps_stats_bot SET botcount=botcount+1, botlast=NOW(), botlasturl='$tlc_thispage' WHERE botname='$searchbot'");
}

?>


http://www.jryouxi.com

http://www.wlyxch.com
[ 此贴被djks在2008-03-19 09:25重新编辑 ]
搜索更多相关文章:网站 数据库 信息 代码
顶端 Posted: 2007-09-25 14:49 | [楼 主]
秋的感觉
级别: PW新手顾问团

 

收到
顶端 Posted: 2007-09-25 14:53 | 1 楼
yayuyao
本站提供两种服务方案  1 您自己买空间,我返还您部分金额。2 由我来代您购买
级别: 四星会员

 

不错。...
顶端 Posted: 2007-09-25 15:08 | 2 楼
豆沙包
专业猥亵幼女          其实人嘛,龌着龌着、龊着龊着也就习惯了
级别: 四星会员

 

到底怎么用?
来个全套的爽一点
顶端 Posted: 2007-09-25 15:09 | 3 楼
iffa
客服专家
级别: 三星会员

 

支持楼主
顶端 Posted: 2007-09-25 15:10 | 4 楼
djks
问君能有几多愁, 恰是一江春水向东流。
级别: 五星会员

 回 3楼(豆沙包) 的帖子

。。。。。。。。

自己导入一下就好了
顶端 Posted: 2007-09-25 15:11 | 5 楼
豆沙包
专业猥亵幼女          其实人嘛,龌着龌着、龊着龊着也就习惯了
级别: 四星会员

 

问题PHP文件怎么用?
难道我把数据导入就会自动偷窥母蜘蛛了?
怎么调用?
顶端 Posted: 2007-09-25 15:16 | 6 楼
大屁股猫猫
级别: 禁止发言

 

用户被禁言,该主题自动屏蔽!
顶端 Posted: 2007-09-25 15:17 | 7 楼
小孩.
爱在2016
级别: 四星会员

 

顶一个
广告位出租
顶端 Posted: 2007-09-25 15:21 | 8 楼
djks
问君能有几多愁, 恰是一江春水向东流。
级别: 五星会员

 

Quote:
引用第6楼豆沙包于2007-09-25 15:16发表的  :
问题PHP文件怎么用?
难道我把数据导入就会自动偷窥母蜘蛛了?
怎么调用?

调用到模板
顶端 Posted: 2007-09-25 15:50 | 9 楼
« 1 2345» Pages: ( 1/5 total )
帖子浏览记录 版块浏览记录
PHPWind Board » 站长交流

Total 0.009689(s) query 4, Time now is:05-18 01:19, Gzip enabled 浙ICP备06001596号
Powered by PHPWind v6.3 RC Certificate Code © 2003-07 PHPWind.com Corporation