asp判断用户浏览器及搜索蜘蛛代码

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
本文章来自www.111cn.net

时间: 2024-07-29 09:26:57

asp判断用户浏览器及搜索蜘蛛代码的相关文章

asp 判断用户浏览器类型程序

Thesoft=Request.ServerVariables("HTTP_USER_AGENT") If instr(thesoft,"Windows NT 5.0") Then  vOS="Win2000" ElseIf instr(thesoft,"Windows NT 5.2") Then  vOs="Win2003" ElseIf instr(thesoft,"Windows NT 5.

PHP判断用户浏览器是否安装alexa工具条程序

众所周知,alexa工具条是常用的网站第三方统计工具,通常我们会自行定制alexa工具条用来让用户安装,通过用户对工具条内容的点击来提高网站在alexa的排名.如下图中河北新闻网的alexa工具条. 如果我们在一些必要的php应用中需要强制用户安装,这就涉及到了alexa工具条安装与否的判断.浏览器在访问网页时php可以获取用户的User-Agent识别字符.使用装有Alexa Toolbar的浏览器在请求网页的时候,User-Agent识别字符中会多出alexa标记.用这个特性就可以判断用户的

asp判断用户是否登陆

dim username,password username=session("user") password=session("pwd") if reqeust("id")<>username then response.write "<script>alert('非法操作');window.location.href='index.asp';</script>" response.end

js判断用户浏览器类型

js判断用户浏览器类型 var lang = new Array(); var userAgent = navigator.userAgent.toLowerCase(); var is_opera = userAgent.indexOf('opera') != -1 && opera.version(); var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('f

微信公众号判断用户是否已关注php代码解析_php实例

现在的活动,很多都引导用户关注公众号,才能参与到活动当中,那如何才能判断用户关注了公众号呢? 本文就为大家提供php代码,解决问题. 官方接口说明 获取用户基本信息(包括UnionID机制)  http://mp.weixin.qq.com/wiki/14/bb5031008f1494a59c6f71fa0f319c66.html 1.只要有基础的access_token和用户openid就可以判断用户是否关注该公众号 2.利用的接口url为:https://api.weixin.qq.com/

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

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

js判断ie浏览器版本与类型代码

ie8以下  代码如下 复制代码 if(!+[1,])   if(window.attachEvent){ alert("ie")}else if(window.addEventListener){alert("not ie")}else{alert("不支持DHTML")} ie6  代码如下 复制代码 if(document.all) 例子  代码如下 复制代码 <script type="text/javascript&qu

微信公众号判断用户是否已关注php代码解析

现在的活动,很多都引导用户关注公众号,才能参与到活动当中,那如何才能判断用户关注了公众号呢? 本文就为大家提供php代码,解决问题. 官方接口说明 获取用户基本信息(包括UnionID机制) http://mp.weixin.qq.com/wiki/14/bb5031008f1494a59c6f71fa0f319c66.html 1.只要有基础的access_token和用户openid就可以判断用户是否关注该公众号 2.利用的接口url为:https://api.weixin.qq.com/c

ASP判断客户端浏览器语言自动跳转

<% dim lan lan=request.servervariables("http_accept_language") select case 1 case instr(lan,"zh-cn") response.redirect("http://www.3lian.com//cn/index.asp教程") '判断客户端是否是中文简体,如果是转向/cn/index.asp case instr(lan,"zh-tw&quo