PDA

查看完整版本 : XMLHTTP POST 接收整个网页


Tony
2004-07-24, 01:17 PM
本帖相关代码如下:

<%
function GetSourceInfo(byval url)
dim xmlhttp,xmlget,bgpos,endpos
Set xmlhttp = CreateObject("Msxml2.ServerXMLHTTP")
strA=server.urlencode("abc")
With xmlhttp
.Open "POST", url, False
.setRequestHeader "Content-Length",len(strA)
.setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded"
.Send strA
if .status<>200 then
xmlget="error"
else
xmlget = bin2str(.responseBody)
end if
End With
set xmlhttp = nothing
GetSourceInfo=xmlget
end function
Function bin2str(binstr)
Const adTypeBinary = 1
Const adTypeText = 2
Dim BytesStream,StringReturn
Set BytesStream = Server.CreateObject("ADODB.Stream") '建立一个流对象
With BytesStream
.Type = adTypeText
.Open
.WriteText binstr
.Position = 0
.Charset = "GB2312"
.Position = 2
StringReturn = .ReadText
.close
End With
Set BytesStream = Nothing
bin2str = StringReturn
End Function
response.write(GetSourceInfo("http://www.xxx.com/index.asp"))
%>