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

首頁 > 開發 > PHP > 正文

通過PHP程序統計蜘蛛是否訪問你的網站

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

  搜索引擎的蜘蛛訪問網站是通過遠程抓取頁面來進行的,我們不能使用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 (+http://www.googlebot.com/bot.html)', 'googlebot', 0, '0000-00-00 00:00:00', '');
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', '');
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+(+http://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;+http://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
*   email                : [email protected]
*   homepage             : http://www.week9.com
*                          http://www.wapshow.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($_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'");
}

?>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 林西县| 克山县| 清苑县| 鹤庆县| 乐平市| 宁夏| 中山市| 星子县| 监利县| 安多县| 杭锦后旗| 徐闻县| 清原| 江阴市| 苏尼特右旗| 婺源县| 内乡县| 诸暨市| 西昌市| 鄱阳县| 郴州市| 磐石市| 姚安县| 积石山| 乌鲁木齐县| 剑阁县| 晋城| 祁连县| 灌云县| 临桂县| 庄浪县| 平度市| 读书| 海原县| 偏关县| 鄂托克前旗| 宁化县| 丰宁| 五台县| 华容县| 政和县|