asp 判断是否为搜索引擎蜘蛛的代码

复制代码 代码如下:
<%
function GetBot()
'查询蜘蛛
dim s_agent
GetBot=""
s_agent=Request.ServerVariables("HTTP_USER_AGENT") ‘关键判断语句
if instr(1,s_agent,"googlebot",1) >0 then
GetBot="google"
end if
if instr(1,s_agent,"msnbot",1) >0 then
GetBot="MSN"
end if
if instr(1,s_agent,"slurp",1) >0 then
GetBot="Yahoo"
end if
if instr(1,s_agent,"baiduspider",1) >0 then
GetBot="baidu"
end if
if instr(1,s_agent,"sohu-search",1) >0 then
GetBot="Sohu"
end if
if instr(1,s_agent,"lycos",1) >0 then
GetBot="Lycos"
end if
if instr(1,s_agent,"robozilla",1) >0 then
GetBot="Robozilla"
end if
end function
if GetBot="baidu" then
'给百度定制的内容
elseif GetBot="google" then
'给google 定制的内容
end if
%>

下面是比较完整的代码需要的朋友也可以参考下。里面还包括了一些客户端信息。
复制代码 代码如下:
Class SystemInfo_Cls
Public Browser, version, platform, IsSearch, AlexaToolbar
Private Sub Class_Initialize()
Dim Agent, Tmpstr
IsSearch = False
If Not IsEmpty(Session("SystemInfo_Cls")) Then
Tmpstr = Split(Session("SystemInfo_Cls"), "|||")
Browser = Tmpstr(0)
version = Tmpstr(1)
platform = Tmpstr(2)
AlexaToolbar = Tmpstr(4)
If Tmpstr(3) = "1" Then
IsSearch = True
End If
Exit Sub
End If
Browser = "unknown"
version = "unknown"
platform = "unknown"
Agent = Request.ServerVariables("HTTP_USER_AGENT")
If InStr(Agent, "Alexa Toolbar") > 0 Then
AlexaToolbar = "YES"
Else
AlexaToolbar = "NO"
End If
If Left(Agent, 7) = "Mozilla" Then '有此标识为浏览器
Agent = Split(Agent, ";")
If InStr(Agent(1), "MSIE") > 0 Then
Browser = "Internet Explorer "
version = Trim(Left(Replace(Agent(1), "MSIE", ""), 6))
ElseIf InStr(Agent(4), "Netscape") > 0 Then
Browser = "Netscape "
Tmpstr = Split(Agent(4), "/")
version = Tmpstr(UBound(Tmpstr))
ElseIf InStr(Agent(4), "rv:") > 0 Then
Browser = "Mozilla "
Tmpstr = Split(Agent(4), ":")
version = Tmpstr(UBound(Tmpstr))
If InStr(version, ")") > 0 Then
Tmpstr = Split(version, ")")
version = Tmpstr(0)
End If
End If
If InStr(Agent(2), "NT 5.2") > 0 Then
platform = "Windows 2003"
ElseIf InStr(Agent(2), "Windows CE") > 0 Then
platform = "Windows CE"
ElseIf InStr(Agent(2), "NT 5.1") > 0 Then
platform = "Windows XP"
ElseIf InStr(Agent(2), "NT 4.0") > 0 Then
platform = "Windows NT"
ElseIf InStr(Agent(2), "NT 5.0") > 0 Then
platform = "Windows 2000"
ElseIf InStr(Agent(2), "NT") > 0 Then
platform = "Windows NT"
ElseIf InStr(Agent(2), "9x") > 0 Then
platform = "Windows ME"
ElseIf InStr(Agent(2), "98") > 0 Then
platform = "Windows 98"
ElseIf InStr(Agent(2), "95") > 0 Then
platform = "Windows 95"
ElseIf InStr(Agent(2), "Win32") > 0 Then
platform = "Win32"
ElseIf InStr(Agent(2), "Linux") > 0 Then
platform = "Linux"
ElseIf InStr(Agent(2), "SunOS") > 0 Then
platform = "SunOS"
ElseIf InStr(Agent(2), "Mac") > 0 Then
platform = "Mac"
ElseIf UBound(Agent) > 2 Then
If InStr(Agent(3), "NT 5.1") > 0 Then
platform = "Windows XP"
End If
If InStr(Agent(3), "Linux") > 0 Then
platform = "Linux"
End If
End If
If InStr(Agent(2), "Windows") > 0 And platform = "unknown" Then
platform = "Windows"
End If
ElseIf Left(Agent, 5) = "Opera" Then '有此标识为浏览器
Agent = Split(Agent, "/")
Browser = "Mozilla "
Tmpstr = Split(Agent(1), " ")
version = Tmpstr(0)
If InStr(Agent(1), "NT 5.2") > 0 Then
platform = "Windows 2003"
ElseIf InStr(Agent(1), "Windows CE") > 0 Then
platform = "Windows CE"
ElseIf InStr(Agent(1), "NT 5.1") > 0 Then
platform = "Windows XP"
ElseIf InStr(Agent(1), "NT 4.0") > 0 Then
platform = "Windows NT"
ElseIf InStr(Agent(1), "NT 5.0") > 0 Then
platform = "Windows 2000"
ElseIf InStr(Agent(1), "NT") > 0 Then
platform = "Windows NT"
ElseIf InStr(Agent(1), "9x") > 0 Then
platform = "Windows ME"
ElseIf InStr(Agent(1), "98") > 0 Then
platform = "Windows 98"
ElseIf InStr(Agent(1), "95") > 0 Then
platform = "Windows 95"
ElseIf InStr(Agent(1), "Win32") > 0 Then
platform = "Win32"
ElseIf InStr(Agent(1), "Linux") > 0 Then
platform = "Linux"
ElseIf InStr(Agent(1), "SunOS") > 0 Then
platform = "SunOS"
ElseIf InStr(Agent(1), "Mac") > 0 Then
platform = "Mac"
ElseIf UBound(Agent) > 2 Then
If InStr(Agent(3), "NT 5.1") > 0 Then
platform = "Windows XP"
End If
If InStr(Agent(3), "Linux") > 0 Then
platform = "Linux"
End If
End If
Else
'识别搜索引擎
Dim botlist, i
botlist = "Google,Isaac,Webdup,SurveyBot,Baiduspider,ia_archiver,P.Arthur,FAST-WebCrawler,Java,Microsoft-ATL-Native,TurnitinBot,WebGather,Sleipnir"
botlist = Split(botlist, ",")
For i = 0 To UBound(botlist)
If InStr(Agent, botlist(i)) > 0 Then
platform = botlist(i) & "搜索器"
IsSearch = True
Exit For
End If
Next
End If
If IsSearch Then
Browser = ""
version = ""
Session("SystemInfo_Cls") = Browser & "|||" & version & "|||" & platform & "|||1|||" & AlexaToolbar
Else
Session("SystemInfo_Cls") = Browser & "|||" & version & "|||" & platform & "|||0|||" & AlexaToolbar
End If
End Sub
End Class

时间: 2024-10-25 21:18:12

asp 判断是否为搜索引擎蜘蛛的代码的相关文章

asp 判断是否为搜索引擎蜘蛛的代码_应用技巧

复制代码 代码如下: <% function GetBot() '查询蜘蛛 dim s_agent GetBot="" s_agent=Request.ServerVariables("HTTP_USER_AGENT") '关键判断语句 if instr(1,s_agent,"googlebot",1) >0 then GetBot="google" end if if instr(1,s_agent,"

PHP判断来访是搜索引擎蜘蛛还是普通用户的代码小结_php实例

1.推荐的一种方法:php判断搜索引擎蜘蛛爬虫还是人为访问代码,摘自Discuz x3.2 <?php function checkrobot($useragent=''){ static $kw_spiders = array('bot', 'crawl', 'spider' ,'slurp', 'sohu-search', 'lycos', 'robozilla'); static $kw_browsers = array('msie', 'netscape', 'opera', 'konq

asp.net(c#)捕捉搜索引擎蜘蛛和机器人_实用技巧

下面是访问日志文件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 Mozi

PHP判断搜索引擎蜘蛛的代码

if(stripos($str,'msnbot')){ //msn         return false;       }       if(stripos($str,'Googlebot')){ //google         return false;       }       if(stripos($str,'Sosospider')){ //soso         return false;       }       if(stripos($str,'Sogou') &&

asp 判断 来自那个搜索引擎

本教程告诉你用asp来判断当前浏览用户来自那里,如果来自那个搜索引擎之类的,下面我们就来看看写法吧.   function getSearchKeyword(sRefererUrl){  //取搜索引擎中的关键字    var p = "("       + "google.+?q=([^&]*)" + "|sina.+?word=([^&]*)"       + "|sohu.+?word=([^&]*)&qu

php 判断访客是否为搜索引擎蜘蛛的函数代码_php技巧

复制代码 代码如下: /** * 判断是否为搜索引擎蜘蛛 * * @author Eddy * @return bool */ function isCrawler() { $agent= strtolower($_SERVER['HTTP_USER_AGENT']); if (!empty($agent)) { $spiderSite= array( "TencentTraveler", "Baiduspider+", "BaiduGame",

PHP屏蔽蜘蛛访问代码及常用搜索引擎的HTTP_USER_AGENT_php技巧

PHP屏蔽蜘蛛访问代码代码: 常用搜索引擎名与 HTTP_USER_AGENT对应值 百度baiduspider 谷歌googlebot 搜狗sogou 腾讯SOSOsosospider 雅虎slurp 有道youdaobot Bingbingbot MSNmsnbot Alexais_archiver function is_crawler() { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $spiders = array( '

php判断搜索引擎蜘蛛爬虫的方法整理

先来看蜘蛛列表   搜索引擎 user-agent(包含) 是否PTR 备注 google Googlebot √ host ip  得到域名:googlebot.com主域名 baidu Baiduspider √ host ip  得到域名:*.baidu.com 或 *.baidu.jp yahoo Yahoo! √ host ip  得到域名:inktomisearch.com主域名 Sogou Sogou × *Sogou web spider/3.0(+http://www.sogo

判断是搜索引擎蜘蛛请求类

问题描述 谁有判断是搜索引擎蜘蛛请求类啊,只判断UserAgent就可以了.不用判断IP段.爬虫名称最好齐一点的,没有分了.求解答. 解决方案 解决方案二:现在的大多数蜘蛛,不告诉你他自己是蜘蛛.解决方案三:引用1楼sp1234的回复: 现在的大多数蜘蛛,不告诉你他自己是蜘蛛. 那我要对搜索引擎返回单独页面怎么做呢?我需要一个判断.解决方案四:引用2楼q5789004的回复: Quote: 引用1楼sp1234的回复: 现在的大多数蜘蛛,不告诉你他自己是蜘蛛. 那我要对搜索引擎返回单独页面怎么做