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

前端之家收集整理的这篇文章主要介绍了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 xmlhttpSet 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 WithSet xmlhttp = NothingEnd Sub

猜你在找的VB相关文章