'我用的疼迅的网页,同时获取IP与归属地,返回值格式为:IP|归属地
On Error Resume Next
Dim httpURL As New System.Uri("http://ip.qq.com/")
Dim httpReq As System.Net.HttpWebRequest = System.Net.WebRequest.Create(httpURL)
httpReq.Method = "GET"
Dim httpResp As System.Net.HttpWebResponse = httpReq.GetResponse()
httpReq.KeepAlive = False
Dim reader As New IO.StreamReader(httpResp.GetResponseStream, System.Text.Encoding.GetEncoding(-0))
Dim respHTML As String = reader.ReadToEnd()
With CreateObject("vbscript.regexp")
.Global = True
.MultiLine = True
.ignorecase = True
.Pattern = "当前的IP为.*?\<.*?\>([^<>]+)[\s\S]*?IP所在地为.*?\<.*?\>([^<>]+)"
If .test(respHTML) Then
With .Execute(respHTML)(0)
Return Replace(.submatches(0) & "|" & .submatches(1), " ", " ")
End With
End If
End With
Return