asp 判断是否为搜索引擎蜘蛛的代码
来源:asp之家 发布时间:2011-03-10 11:03:00
代码如下:
<%
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
猜你喜欢
- 一、定位 oracle分两大块,一块是开发,一块是管理。开发主要是写写存储过程、触发器什么的,还有就是用Oracle的Develop工具做f
- 扪心自问,你真正了解你卖给用户的是什么玩意么?你所认为革命性的,一定会震惊世界的功能、特色,用户真的买单么?我的意思是,我们总是习惯性的忘记
- RSS是 Really Simple Syndication的缩写(对rss2.0而言,是这三个词的缩写,对rss1.0而言则是RDF Si
- 一个不错的网页拾色器也叫调色版,请看截图:当想要更多颜色时点击“其它颜色...”此时将调用系统自带的那个颜色选择框:注意:只有把〈scrip
- 数据库安全性问题一直是围绕着数据库管理员的恶梦,数据库数据的丢失以及数据库被非法用户的侵入使得数据库管理员身心疲惫不堪。围绕数据库的安全性问
- 用于操作数据库的SQL一般分为两种,一种是查询语句,也就是我们所说的 SELECT语句,另外一种就是更新语句,也叫做数据操作语句。言外之 意
- 实验目的:验证主动释放内存变量是否有价值. 实验原始代码: <script language=vbscript runat=serve
- 本文介绍了prototype.js常用函数及其使用方法例子说明函数名
- 大家知道,在js里encodeURIComponent 方法是一个比较常用的编码方法,但因工作需要,在asp里需用到此方法,查了好多资料,没
- 随着网页技术的发展,网络视觉设计与之前以程序员为主导的审美特征相比,具有了极大的改观。同时,随着美术、音乐、舞蹈人才的加入,网络开始在这一社
- asp禁止站外盗链,站外提交方法、以及asp判断星期几方法.防盗链,主要通过判断上一页面来源是否是本站来实现的,不是本站的链接就
- 下面是一份在 HTML 4 Strict 和 XHTML 1.0 Strict 下必须遵守的标签嵌套规则,比如你不能在 <a>
- 设置cookie每个cookie都是一个名/值对,可以把下面这样一个字符串赋值给document.cookie:document.cooki
- 原文:10 Principles Of Effective Web Design翻译:熊猫2008-02-03本文由熊猫同学授权翻译首发。并
- 如何用ASP获知机器的网络配置?看看我们的例子:Option Explicit Dim WSHShell&nb
- 突发奇想,写了以下这段代码,感觉还不错,拿来和大家分享作用:查看页面布局使用方法:在页面底部包含以下这段代码ff3,ie7测试可用var&n
- 注册模块default.asp 代码如下:<!DOCTYPE html PUBLIC "-//
- <%'============================================================
- 经常看见有人问,MSSQL占用了太多的内存,而且还不断的增长;或者说已经设置了使用内存,可是它没有用到那么多,这是怎么一回事儿呢? 首先,我
- 经过了上个星期的努力学习,对处理html又有了新的发现感觉真的很不错可以说js的威力在处理html代码方面我又有所领悟了1、截取特定长度字符