<% ' 蜘蛛机器人 function spiderbot() Dim Url,GetLocationURL Dim ServerPort,ServerName,ScriptName,QueryString ServerName = Request.ServerVariables("SERVER_NAME") ServerPort = Request.ServerVariables("SERVER_PORT") ScriptName = Request.ServerVariables("SCRIPT_NAME") QueryString = Request.ServerVariables("QUERY_STRING") Url=""&;ServerName If ServerPort <> "80" Then Url = Url &; ":" &; ServerPort Url=Url&;ScriptName If QueryString <>"" Then Url=Url&;"?"&; QueryString GetLocationURL=Url dim agent: agent = lcase(request.servervariables("http_user_agent")) dim Bot: Bot = "" if instr(agent, "googlebot") > 0 then Bot = "Google" if instr(agent, "mediapartners-google") > 0 then Bot = "Google Adsense" if instr(agent, "baiduspider") > 0 then Bot = "Baidu" if instr(agent, "sogou spider") > 0 then Bot = "Sogou" if instr(agent, "yahoo") > 0 then Bot = "Yahoo!" if instr(agent, "msn") > 0 then Bot = "MSN" if instr(agent, "ia_archiver") > 0 then Bot = "Alexa" if instr(agent, "iaarchiver") > 0 then Bot = "Alexa" if instr(agent, "sohu") > 0 then Bot = "Sohu" if instr(agent, "sqworm") > 0 then Bot = "AOL" if instr(agent, "yodaobot") > 0 then Bot = "Yodao" if instr(agent, "iaskspider") > 0 then Bot = "Iask" if len(Bot) > 0 then Dim oConn, dbPath, adOpenDynamic, adLockPessi
mistic,sqll set oConn=server.createobject("ADODB.connection") oConn.Open "DBQ="+server.mappath("./zhizhu/bot.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};" Dim oRS set oRS=Server.Createobject("ADODB.Recordset") sqll="select * from bot" oRS.open
sqll, oConn,2,2 oRS.AddNew oRS("bot") = bot
oRS("shijian") = now() oRS("url") = GetLocationURL oRS.Update oRS.Close oConn.close end if end function %> <%call spiderbot()%> 这个用来记录
搜索站的蜘蛛,从而写入到名为 bot.mdb 的数据库里 <% dim conn,rs,connstr connstr="DBQ="+server.mappath("bot.mdb")+";DefaultDir=;DRIVER={Microsoft Driver (*.mdb)};" set conn=server.createobject("ADODB.CONNECTION") conn.open connstr set rs=server.createobject("adodb.recordset") sql="select * from bot order by id desc" rs.open sql,conn,1,1
Access
%> <
HTML >
ID | 蜘蛛 | 来访时间 | 页面 URL |
<%do while not rs.eof %> <%=rs("id")%> | <%=rs("bot")%> | <%=rs("shijian")%> | <%=rs("url")%> |
<%rs.movenext loop rs.close %>
<% set rs=nothing conn.close set conn=nothing %> 以上代码为读取 bot.mdb 数据库中的蜘蛛访问数据 只能读取,不能删除 :-)