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-04 16:28:16

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

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

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,"

ASP.net中网站访问量统计方法代码_实用技巧

一.建立一个数据表IPStat用于存放用户信息 我在IPStat表中存放的用户信息只包括登录用户的IP(IP_Address),IP来源(IP_Src)和登录时间(IP_DateTime),些表的信息本人只保存一天的信息,如果要统计每个月的信息则要保存一个月.因为我不太懂对数据日志的操作,所以创建此表,所以说我笨吧,哈哈. 二.在Global.asax中获取用户信息 在Global.asax的Session_Start即新会话启用时获取有关的信息,同时在这里实现在线人数.访问总人数的增量统计,代

ASP替换、保存远程图片实现代码_应用技巧

ASP通过函数来实现替换.保存远程图片,完成自动采集图片.提取图片的功能,函数中自动判断重复图片,智能分析链接路径,并转成成相对的图片地址保存在你指定的网站目录中,我们可将此函数用在后台的编辑器中,当你复制了含有图片的内容后,本代码会自动帮你上传图片.同时本代码也是采集程序中的重要处理函数,函数代码如下: Function ReplaceSaveRemoteFile(ConStr,strInstallDir,strChannelDir,SaveTf,TistUrl) If ConStr="$Fa

ASP所有的Session变量获取实现代码_应用技巧

复制代码 代码如下: Dim strName, iLoop For Each strName in Session.Contents Response.Write strName & " - " & Session.Contents(strName)& "[BR]" Next 一般情况下,上面的代码可以工作得很好.但当Session变量是一个对象或者数组时,打印的结果就不正确了. 这样我们修改代码如下: 复制代码 代码如下: '首先看看有多少

asp下使用数组存放数据的代码_应用技巧

asp用客户端数组存放数据,这种应用我已经见过很多.但最近在研究几套流量交换联盟系统时,这种技术才引起了我的注意. 下面我讲讲如何运用,先给出个没有结合ASP,就单纯适用javascript的例子. 1.js 复制代码 代码如下: var a = new Array();  var temp = "<table>";  a[0] = new Array(1,"阿会楠","男");   a[1] = new Array(2,"

asp.net 用户在线退出更新实现代码_实用技巧

最主要的问题是关闭浏览器的时候如何更新用户在线列表 网上流传的方法是不停的ajax异步发送请求,当不再请求的时候就可以判断用户已经关闭浏览器 复制代码 代码如下: var x=0; function myRefresh() { var httpRequest = new ActiveXObject("microsoft.xmlhttp"); httpRequest.open("GET", "test.aspx", false); httpRequ

asp中&amp;quot;无限流&amp;quot;分页程序代码_应用技巧

<% '****************************************************************** '** 本程序名:"无限流"分页程序 '** 作者:Arbiter(AAsx) '** 版本:Million Level '** '** QQ:22222xx '** Email:Arbiter@21cn.com '** http://www.imagecity.org/ '*********************************

asp+ajax仿google搜索提示效果代码_应用技巧

对于更完整的代码可以参考,这个是支持数据库的版本.经过编辑测试.Asp+Ajax仿google搜索提示效果 数据库版需要修改的地方有 复制代码 代码如下: javascript.js var url="ajax.asp"; //后台地址 var time_delayajax=300; //搜索延迟 var time_delayupdown=100; //方向键延迟 obj_div.style.top = (xtop + 20) + "px"; //20差不多是输入框