`
xitong
  • 浏览: 6159011 次
文章分类
社区版块
存档分类
最新评论

VB使用xmlhttp获取远程网页内容

 
阅读更多

Dim xmlHttp As Object

Private Function aaa(url As String)
Set xmlHttp = CreateObject("Microsoft.XMLHTTP")
xmlHttp.Open "GET", url, True
xmlHttp.send (Null)
While xmlHttp.ReadyState <> 4
DoEvents
Wend
aaa = xmlHttp.responseText
End Function

Sub sheep()
MsgBox aaa("http://www.baidu.com")
End Sub

'==============================一下是POST数据实例====================

Sub test2()
Dim xmlhttp
Set xmlhttp = CreateObject("msxml2.xmlhttp")
With xmlhttp
.Open "POST", "http://127.0.0.1:8012/json.php?mode=9", False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send "mode=9"
MsgBox .responseText '显示POST之后网页返回的结果
End With
Set xmlhttp = Nothing
End Sub

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics