asp.net(c#)捕捉搜索引擎蜘蛛和機器人
更新時間:2008年08月16日 13:37:25 作者:
結(jié)合這個你就可以寫一個蜘蛛訪問記錄了,如何判斷正常用戶或者蜘蛛?可以粗略的這樣來判斷:通過判斷用戶的訪問來源頁面
下面是訪問日志文件
2008-8-13 14:43:22
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)
2008-8-13 14:43:27
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)
2008-8-13 14:44:18
Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)
2008-8-13 14:44:26
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; QQDownload 1.7; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
2008-8-13 14:45:17
Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)
打開這個文件,這個文件用于記錄訪問搜索吧的正常訪客或者機器人蜘蛛,從中提取的蜘蛛有: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
Gigabot/3.0 (http://www.gigablast.com/spider.html)
Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)
Mozilla/5.0 (compatible; YodaoBot/1.0; http://www.yodao.com/help/webmaster/spider/; )
Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)
msnbot/1.1 (+http://search.msn.com/msnbot.htm)
Baiduspider+(+http://www.baidu.com/search/spider.htm)
代碼也十分的簡單:
string agent = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"];
if (agent == null)
{
Response.Write("Other");
}
else
{
Response.Write(agent);
}
你可以自己用這個代碼試下,發(fā)現(xiàn)會輸出類似: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler 4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322)
結(jié)合這個你就可以寫一個蜘蛛訪問記錄了,如何判斷正常用戶或者蜘蛛?可以粗略的這樣來判斷:通過判斷用戶的訪問來源頁面,比如從jb51.net/index.htm這個文件點進show.asp?id=11那么他的來源頁面我們知道就是jb51.net/index.htm,那么粗略判斷他就是正常客戶。而蜘蛛的來源則不是,把這部分不是的記錄下來,再從中選擇??梢越Y(jié)合數(shù)據(jù)庫進行記錄。
2008-8-13 14:43:22
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)
2008-8-13 14:43:27
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)
2008-8-13 14:44:18
Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)
2008-8-13 14:44:26
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; QQDownload 1.7; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
2008-8-13 14:45:17
Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)
打開這個文件,這個文件用于記錄訪問搜索吧的正常訪客或者機器人蜘蛛,從中提取的蜘蛛有: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
Gigabot/3.0 (http://www.gigablast.com/spider.html)
Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)
Mozilla/5.0 (compatible; YodaoBot/1.0; http://www.yodao.com/help/webmaster/spider/; )
Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)
msnbot/1.1 (+http://search.msn.com/msnbot.htm)
Baiduspider+(+http://www.baidu.com/search/spider.htm)
代碼也十分的簡單:
復制代碼 代碼如下:
string agent = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"];
if (agent == null)
{
Response.Write("Other");
}
else
{
Response.Write(agent);
}
你可以自己用這個代碼試下,發(fā)現(xiàn)會輸出類似: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler 4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322)
結(jié)合這個你就可以寫一個蜘蛛訪問記錄了,如何判斷正常用戶或者蜘蛛?可以粗略的這樣來判斷:通過判斷用戶的訪問來源頁面,比如從jb51.net/index.htm這個文件點進show.asp?id=11那么他的來源頁面我們知道就是jb51.net/index.htm,那么粗略判斷他就是正常客戶。而蜘蛛的來源則不是,把這部分不是的記錄下來,再從中選擇??梢越Y(jié)合數(shù)據(jù)庫進行記錄。
相關(guān)文章
ASP.NET2.0數(shù)據(jù)庫入門之SQL Server
ASP.NET2.0數(shù)據(jù)庫入門之SQL Server...2006-09-09
Asp.net之TextBox只允許輸入數(shù)字的方法總結(jié)
Asp.net之TextBox只允許輸入數(shù)字的方法總結(jié),需要的朋友可以參考一下2013-02-02
uni-app結(jié)合.NET?7實現(xiàn)微信小程序訂閱消息推送
本文主要介紹了uni-app結(jié)合.NET?7實現(xiàn)微信小程序訂閱消息推送,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-02-02

