您所在的位置:小祥子 » 编程 » ASP » 正文

ASP判断蜘蛛是否到访并记录到数据库

时间:2015-02-21 编辑:本站 来源:本站原创

ASP判断蜘蛛并且记录到数据库内。

使用方法

Call spiderbot()

代码如下

Function spiderbot()
 dim agent
 agent = lcase(request.servervariables("http_user_agent"))
 dim Bot: Bot = ""
 
 '百度
 if instr(agent, "baiduspider") > 0 then Bot = "百度"
 if instr(agent, "baiduspider-image") > 0 then Bot = "百度图片"
 if instr(agent, "baiducustomer") > 0 then Bot = "百度"
 if instr(agent, "baidu-thumbnail") > 0 then Bot = "百度"
 if instr(agent, "baiduspider-mobile-gate") > 0 then Bot = "百度"
 if instr(agent, "baidu-transcoder/1.0.6.0") > 0 then Bot = "百度"
 '谷歌google
 if instr(agent, "googlebot/2.1") > 0 then Bot = "谷歌"
 if instr(agent, "googlebot-image/1.0") > 0 then Bot = "谷歌"
 if instr(agent, "feedfetcher-google") > 0 then Bot = "谷歌"
 if instr(agent, "mediapartners-google") > 0 then Bot = "谷歌"
 if instr(agent, "adsbot-google") > 0 then Bot = "谷歌"
 if instr(agent, "googlebot-mobile/2.1") > 0 then Bot = "谷歌"
 if instr(agent, "googlefriendconnect/1.0") > 0 then Bot = "谷歌"
 '雅虎yahoo
 if instr(agent, "yahoo! slurp;") > 0 then Bot = "雅虎"
 if instr(agent, "yahoo! slurp/3.0") > 0 then Bot = "雅虎"
 if instr(agent, "yahoo! slurp china") > 0 then Bot = "雅虎"
 if instr(agent, "yahoofeedseeker/2.0") > 0 then Bot = "雅虎"
 if instr(agent, "yahoo-blogs") > 0 then Bot = "雅虎"
 if instr(agent, "yahoo-mmcrawler") > 0 then Bot = "雅虎"
 if instr(agent, "yahoo contentmatch crawler") > 0 then Bot = "雅虎"
 '微软bing
 if instr(agent, "msnbot/1.1") > 0 then Bot = "微软bing"
 if instr(agent, "msnbot/2.0b") > 0 then Bot = "微软bing"
 if instr(agent, "msrabot/2.0/1.0") > 0 then Bot = "微软bing"
 if instr(agent, "msnbot-media/1.0") > 0 then Bot = "微软bing"
 if instr(agent, "msnbot-products") > 0 then Bot = "微软bing"
 if instr(agent, "msnbot-academic") > 0 then Bot = "微软bing"
 if instr(agent, "msnbot-newsblogs") > 0 then Bot = "微软bing"
 '360
 if instr(agent, "360spider") > 0 then Bot = "360搜索"
 '腾讯搜搜soso
 if instr(agent, "sosospider") > 0 then Bot = "腾讯搜搜"
 if instr(agent, "sosoblogspider") > 0 then Bot = "腾讯搜搜"
 if instr(agent, "sosoimagespider") > 0 then Bot = "腾讯搜搜"
 '网易有道
 if instr(agent, "youdaobot/1.0") > 0 then Bot = "网易有道"
 if instr(agent, "yodaobot-image/1.0") > 0 then Bot = "网易有道"
 if instr(agent, "yodaobot-reader/1.0") > 0 then Bot = "网易有道"
 '搜狐搜狗
 if instr(agent, "sogou web robot") > 0 then Bot = "搜狗"
 if instr(agent, "sogou web spider/3.0") > 0 then Bot = "搜狗"
 if instr(agent, "sogou web spider/4.0") > 0 then Bot = "搜狗"
 if instr(agent, "sogou head spider/3.0") > 0 then Bot = "搜狗"
 if instr(agent, "sogou-test-spider/4.0") > 0 then Bot = "搜狗"
 if instr(agent, "sogou orion spider/4.0") > 0 then Bot = "搜狗"
 'Alexa
 if instr(agent, "ia_archiver") > 0 then Bot = "Alexa"
 if instr(agent, "iaarchiver") > 0 then Bot = "Alexa"
 '奇虎
 if instr(agent, "qihoo") > 0 then Bot = "Qihoo"
 'ASK.com
 if instr(agent, "ask jeeves/teoma") > 0 then Bot = "Ask Jeeves/Teoma"
 if len(Bot) > 0 then
  set rs = server.CreateObject ("adodb.recordset")
  sql="select [Botname],[LastDate] From ["&tbname&"_Bots] Where [Botname]='" & Bot & "'"
  rs.open sql,conn,1,3
  if rs.eof and rs.bof then
  rs.AddNew
  rs(0) = Bot
  rs(1) = now()
  else
  rs(1) = now()
  end if
  rs.update
  rs.close: set rs = nothing
 end if
end Function