On Error Resume Next
Dim ip,cs As String
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)
Vars("本机IP") = Replace(.submatches(0) & "|" & .submatches(1), " ", "|").split("|")(0)
Vars("本机城市") = Replace(.submatches(0) & "|" & .submatches(1), " ", "|").split("|")(1)
End With
End If
End With