Foxtable(狐表)用户栏目专家坐堂 → 如何获取本机的公网IP


  共有2813人关注过本帖树形打印复制链接

主题:如何获取本机的公网IP

帅哥哟,离线,有人找我吗?
ruan
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:467 积分:4928 威望:0 精华:0 注册:2011/8/20 18:40:00
  发帖心情 Post By:2019/4/12 11:17:00 [显示全部帖子]

Dim httpURL As New System.Uri("http://2019.ip138.com/ic.asp")
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()


Dim wip As String  ''外网IP
Dim qy As String   '.IP所属区域

Dim mc = System.Text.RegularExpressions.Regex.Matches(respHTML , "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")
If mc.count > 0 Then
    wip = mc(0).value
    Dim ss As String = respHTML.SubString(respHTML.IndexOf("来自")+3)
    qy = ss.SubString(0,ss.IndexOf("<"))
End If
 


 回到顶部