xmlhttp
(创建时间:2008年04月18日 18:10:00)
Jangogo :
Set xmlHttp = CreateObject("microsoft.xmlhttp")
Set oShell = CreateObject("WScript.Shell")
sCurrDir = oShell.CurrentDirectory
Function GetPage(Method,Url,Async,PostContent,FileName)
xmlHttp.open Method,Url,Async
If Method = "POST" Then
xmlhttp.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
xmlhttp.setRequestHeader "Content-Length",Len(PostContent)
End If
xmlHttp.send(PostContent)
If Async = False Then GetPage = BytesToBstr(xmlHttp.responseBody,"GB2312",FileName) Else GetPage = ""
End Function
Function BytesToBstr(body,Cset,FileName)
Set objstream = CreateObject("ADODB.Stream")
with objstream
.Type = 1
.Mode =3
.Open
.Write body
If not trim(FileName)="" Then .SaveToFile LCase(FileName),2
.Position = 0
.Type = 2
.Charset = Cset
End With
BytesToBstr = objstream.ReadText
objstream.Close
End Function
使用方法:
GetPage(提交方法, 提交URL, 是否异步, POST内容, [另存为文件名])
几乎封装了一切可用的,呵呵。以后用xmlHttp做刷网页,破密码等,都是很简单的调用了。效率很高,直接继承了IE的Cookie。
Set oShell = CreateObject("WScript.Shell")
sCurrDir = oShell.CurrentDirectory
Function GetPage(Method,Url,Async,PostContent,FileName)
xmlHttp.open Method,Url,Async
If Method = "POST" Then
xmlhttp.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
xmlhttp.setRequestHeader "Content-Length",Len(PostContent)
End If
xmlHttp.send(PostContent)
If Async = False Then GetPage = BytesToBstr(xmlHttp.responseBody,"GB2312",FileName) Else GetPage = ""
End Function
Function BytesToBstr(body,Cset,FileName)
Set objstream = CreateObject("ADODB.Stream")
with objstream
.Type = 1
.Mode =3
.Open
.Write body
If not trim(FileName)="" Then .SaveToFile LCase(FileName),2
.Position = 0
.Type = 2
.Charset = Cset
End With
BytesToBstr = objstream.ReadText
objstream.Close
End Function
使用方法:
GetPage(提交方法, 提交URL, 是否异步, POST内容, [另存为文件名])
几乎封装了一切可用的,呵呵。以后用xmlHttp做刷网页,破密码等,都是很简单的调用了。效率很高,直接继承了IE的Cookie。
任务记录:
已归档改进建议
1楼
2楼
4楼
5楼
6楼