function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "POST",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function
Private 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
Dim Str_Url,Result
Result = getHTTPPage(Str_Url)
ASP.NET 中的 HTTP 请求处理
本文介绍了一个使用 ASP.NET 和 MSXML2.XMLHTTP 对象进行 HTTP POST 请求的方法。通过示例展示了如何发送请求并接收响应,同时解析响应体为 GB2312 编码的字符串。
2923

被折叠的 条评论
为什么被折叠?



