使用xmlHTTP对象,可以这样: 新建一个标准模块,写入:Option Explicit Public Function GetCode(CodeBase, url, Data) On Error GoTo HandleErr: Dim xmlHTTP1 Set xmlHTTP1 = CreateObject("Microsoft.XMLHTTP") xmlHTTP1.Open "get", url, True xmlHTTP1.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" xmlHTTP1.send Data While xmlHTTP1.ReadyState <> 4 DoEvents Wend GetCode = xmlHTTP1.responseBody If CStr(GetCode) <> "" Then GetCode = BytesToBstr(GetCode, CodeBase) Set xmlHTTP1 = Nothing Exit Function HandleErr:End FunctionPublic Function BytesToBstr(strBody, CodeBase) Dim ObjStream Set ObjStream = CreateObject("Adodb.Stream") With ObjStream .Type = 1 .Mode = 3 .Open .Write strBody .Position = 0 .Type = 2 .Charset = CodeBase BytesToBstr = .ReadText .Close End With Set ObjStream = Nothing End Function 然后,在你需要Post提交的地方使用方法getcode, dim retHtml as string rethtml = getcode(字符集, URL, 参数)字符集可以自己查看网页源代码,UTF-8 或 GB2312
新建一个标准模块,写入:Option Explicit
Public Function GetCode(CodeBase, url, Data)
On Error GoTo HandleErr:
Dim xmlHTTP1
Set xmlHTTP1 = CreateObject("Microsoft.XMLHTTP")
xmlHTTP1.Open "get", url, True
xmlHTTP1.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlHTTP1.send Data
While xmlHTTP1.ReadyState <> 4
DoEvents
Wend
GetCode = xmlHTTP1.responseBody
If CStr(GetCode) <> "" Then GetCode = BytesToBstr(GetCode, CodeBase)
Set xmlHTTP1 = Nothing
Exit Function
HandleErr:End FunctionPublic Function BytesToBstr(strBody, CodeBase)
Dim ObjStream
Set ObjStream = CreateObject("Adodb.Stream")
With ObjStream
.Type = 1
.Mode = 3
.Open
.Write strBody
.Position = 0
.Type = 2
.Charset = CodeBase
BytesToBstr = .ReadText
.Close
End With
Set ObjStream = Nothing
End Function
然后,在你需要Post提交的地方使用方法getcode,
dim retHtml as string
rethtml = getcode(字符集, URL, 参数)字符集可以自己查看网页源代码,UTF-8 或 GB2312