<%
Function GetBody(weburl)
Set Retrieval = Server.CreateObject("MSXML2.XMLHTTP")
With Retrieval
.Open "Get", weburl, False, "", ""
.setRequestHeader "referer","http://www.abc.com/"'
.Send
GetBody = .ResponseBody
End With
GetBody = BytesToBstr(GetBody,"GB2312")
Set Retrieval = Nothing
End Function
Function BytesToBstr(body,Cset)
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 = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Response.Write(GetBody("http://www.devdao.com/referer.asp"))
%>
========================================================
方法1
OnErrorResumeNextSethttp=Server.CreateObject("Msxml2.ServerXMLHTTP.7.0")IfErrThenErr.Clear
Sethttp=Server.CreateObject("Msxml2.ServerXMLHTTP.6.0")IfErrThenErr.Clear
Sethttp=Server.CreateObject("Msxml2.ServerXMLHTTP.5.0")IfErrThenErr.Clear
Sethttp=Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")IfErrThenErr.Clear
Sethttp=Server.CreateObject("Msxml2.ServerXMLHTTP")IfErrThenErr.ClearResponse.Write"服務(wù)器不支持Msxml,本程序無法運(yùn)行!"Response.EndEndIfEndIfEndIfEndIfEndIfOnErrorGoto0
段下載DownStartTime=Now()
DoBlockStartTime=Timer()
http.open"GET",RemoteFileUrl,true,"",""'用異步方式調(diào)用serverxmlhttp
'構(gòu)造http頭http.setRequestHeader"Referer",RefererUrlhttp.setRequestHeader"Accept","*/*"http.setRequestHeader"User-Agent","Baiduspider+(+http://www.baidu.com/search/spider.htm)"'偽裝成Baidu'http.setRequestHeader"User-Agent","Googlebot/2.1(+http://www.google.com/bot.html)"'偽裝成Googlehttp.setRequestHeader"Range","bytes="&RangeStart&"-"&Cstr(RangeStart+BlockSize-1)'分段關(guān)鍵http.setRequestHeader"Content-Type","application/octet-stream"http.setRequestHeader"Pragma","no-cache"http.setRequestHeader"Cache-Control","no-cache"
http.send'發(fā)送
=============================
方法2
《
if request("turl")<>"" then
dim xmlhttp
set xmlhttp = createobject("Microsoft.XMLHTTP")
xmlhttp.open "POST",request("turl"), false
xmlhttp.setRequestHeader "referer","http://202.96.140.49:4385/"
xmlhttp.setRequestHeader"User-Agent","Baiduspider+(+http://www.baidu.com/search/spider.htm)"'偽裝成Baidu
'xmlhttp.setRequestHeader "HOST","http://202.96.140.49" 這個(gè)還沒有驗(yàn)證
xmlhttp.setRequestHeader "Content-Length",Len(strRequest)
xmlhttp.setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded"
xmlhttp.send(strRequest)
bytes2BSTR(xmlhttp.responseBody)
end if
Function bytes2BSTR(vIn)
dim strReturn
dim i,ThisCharCode,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
response.write Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
response.write Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
End Function
》