by 清泉
10. 四月 2009 08:04
ASP获取POST网页内容的函数。
函数中参数的说明:
RefererUrl:来源页面地址
PostUrl:Form提交页面地址
PostData:提交的数据。(如:username=username&password=password如此类推)
Coding:网页的编码格式
Function PostHttpPage(RefererUrl, PostUrl, PostData, Coding)
On Error Resume Next
Dim xmlHttp
Dim RetStr
Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP")
xmlHttp.Open "POST", PostUrl, False
xmlHttp.setRequestHeader "Content-Length", Len(PostData)
xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlHttp.setRequestHeader "Referer", RefererUrl
xmlHttp.Send PostData
If Err Then
Set xmlHttp = Nothing
PostHttpPage = "$False$"
Exit Function
End If
If Coding = 1 Then
PostHttpPage = BytesToBstr(xmlHttp.ResponseBody, "UTF-8")
ElseIf Coding = 2 Then
PostHttpPage = BytesToBstr(xmlHttp.ResponseBody, "Big5")
Else
PostHttpPage = BytesToBstr(xmlHttp.ResponseBody, "GB2312")
End If
Set xmlHttp = Nothing
End Function