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

首頁 > 開發 > PHP > 正文

通過PHP程序知道蜘蛛是否訪問你的網站(附代碼)

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

搜索引擎的蜘蛛訪問網站是通過遠程抓取頁面來進行的,我們不能使用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'");
}

?>



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 抚顺县| 华容县| 两当县| 清水县| 沙坪坝区| 临泉县| 明水县| 区。| 秦皇岛市| 登封市| 洛南县| 河池市| 城口县| 渭南市| 阳谷县| 泉州市| 利川市| 乡宁县| 崇仁县| 双流县| 崇文区| 汉中市| 定兴县| 台南市| 分宜县| 科技| 海林市| 盐山县| 临江市| 灵璧县| 阳东县| 葫芦岛市| 尉氏县| 瓦房店市| 合阳县| 东光县| 商水县| 罗田县| 阳曲县| 山东| 玉田县|