第一种:
str = "xx=xxxx"
set objHttp = CreateObject("MSXML2.ServerXMLHTTP")
objHttp.open "POST", "http://xxx/xx.asp", false
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.Send str
if (objHttp.status <> 200 ) then
'HTTP 错误处理
msg = "Status="&objHttp.status
else
msg=objHttp.responseText
end if
Set objHttp = Nothing
第二种:
msg = getHTTPPage(url)
Function getHTTPPage(url)
dim objXML
set objXML=createobject("MSXML2.XMLHTTP")
objXML.open "post",url,false
objXML.send()
If objXML.readystate<>4 then
exit function
End If
getHTTPPage=BytesToBstr(objXML.responseBody)
set objXML=nothing
if err.number<>0 then err.Clear
End Function
Function BytesToBstr(body)
dim objstream
set objstream = 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