<%
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"服务器不支持Msxml,本程序无法运行!"Response.EndEndIfEndIfEndIfEndIfEndIfOnErrorGoto0
段下载DownStartTime=Now()
DoBlockStartTime=Timer()
http.open"GET",RemoteFileUrl,true,"",""'用异步方式调用serverxmlhttp
'构造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)'分段关键http.setRequestHeader"Content-Type","application/octet-stream"http.setRequestHeader"Pragma","no-cache"http.setRequestHeader"Cache-Control","no-cache"
http.send'发送
=============================
方法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" 这个还没有验证
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
》