VBA常见访问网络的方式有2种,一种是GET,一种是POST
GET示例代码有2种写法:
第1种:
Public Function MobileAddr(mobstr As String)
Dim xmlHttp As Object
Set xmlHttp = CreateObject("MSXML2.XMLHTTP")
’-------------------
xmlHttp.Open "GET", "https://www.ip138.com/mobile.asp?mobile=" + mobstr + "&action=mobile"
xmlHttp.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36 SE 2.X MetaSr 1.0"
xmlHttp.Send
’-------------------
Do While xmlHttp.ReadyState <> 4
DoEvents
Loop
’------