IT猫扑网:您身边最放心的安全下载站! 最新更新|软件分类|软件专题|手机版|论坛转贴|软件发布

您当前所在位置:首页网络编程PHP编程 → 用PHP程序统计蜘蛛是否访问你的网站

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

时间:2015/6/28来源:IT猫扑网作者:网管联盟我要评论(0)

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

数据库结构:

#
# 表的结构 `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 (+https://www.googlebot.com/bot.html)', 'googlebot', 0, '0000-00-00 00:00:00', '');
INSERT INTO `naps_stats_bot` VALUES (2, 'MSNbot', 'MSNBOT/0.1 (https://search.msn.com/msnbot.htm)', '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+(+https://www.baidu.com/search/spider.htm)', 'baiduspider', 0, '0000-00-00 00:00:00', '');
INSERT INTO `naps_stats_bot` VALUES (5, 'Yahoobot', 'Mozilla/5.0+(compatible;+Yahoo!+Slurp;+https://help.yahoo.com/help/us/ysearch/slurp)', '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程序:

/***************************************************************************
* NAPS -- Network Article Publish System
* ----------------------------------------------
*                                 bot.php
*                            -------------------
*   begin                : 2004-08-15
*   copyright            : (C) 2004 week9
*   homepage             : https://www.itmop.com
*                          https://bbs.itmop.com 
*
***************************************************************************/

/***************************************************************************
*
*   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(
___FCKpd___0
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(
___FCKpd___0
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'"); } ?>

关键词标签:访问,网站,是否,蜘蛛,

相关阅读 原神回声海螺位置-原神回声海螺攻略ASP代码中如何屏蔽ip地址 禁止某IP段访问网站解决VPN路由设置不能访问外网的问题Apache下的目录共享访问和认证利用A、G、DL、P策略来管理网络资源访问权限在Oracle里设置访问多个SQL Server

文章评论
发表评论

热门文章 plsql developer怎么连接数据库-plsql deveplsql developer怎么连接数据库-plsql deve2021年最好用的10款php开发工具推荐2021年最好用的10款php开发工具推荐在 PHP 中使用命令行工具在 PHP 中使用命令行工具php应用程序安全防范技术研究php应用程序安全防范技术研究

相关下载

人气排行 详解ucenter原理及第三方应用程序整合思路、方法PHP中防止SQL注入攻击PHP会话Session的具体使用方法解析PHP运行出现Notice : Use of undefined constant 的解决办法CakePHP程序员必须知道的21条技巧PHP采集图片实例(PHP采集)PHP如何清空mySQL数据库plsql developer怎么连接数据库-plsql developer连接数据库方法