Dim s As String
Dim urls As New List(Of String) From {"http://ipinfo.io/ip", "http://ifconfig.me", "http://members.3322.org/dyndns/getip", "http://myip.ipip.net"}
For Each url As String In urls
Dim hc As New HttpClient(url)
Output.Show("【" & url & "】" & hc.StatusCode)
If hc.StatusCode = "200" Then
If hc.GetData() > "" Then
s = "请检查数据库白名单是否含【" & url & "】返回本机ipv4地址:【" & hc.GetData() & "】。"
Exit For
End If
End If
hc.Close()
Next
Output.Show("s:" & s)
以上代码输出结果如下不正确,百思不得其解,麻烦老师看一下,谢谢!
【http://ipinfo.io/ip】0
【http://ifconfig.me】0
【http://members.3322.org/dyndns/getip】0
【http://myip.ipip.net】0
s:
[此贴子已经被作者于2024/5/9 9:56:11编辑过]
Dim s As String
Dim urls As New List(Of String) From {"http://ipinfo.io/ip", "http://ifconfig.me", "http://members.3322.org/dyndns/getip", "http://myip.ipip.net"}
For Each url As String In urls
Dim hc As New HttpClient(url)
hc.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
hc.GetInformation()
Output.Show("【" & url & "】" & hc.StatusCode)
If hc.StatusCode = "200" Then
Dim a As String = hc.GetData()
If a > "" Then
s = "请检查数据库白名单是否含【" & url & "】返回本机ipv4地址:【" & a & "】。"
Exit For
End If
End If
hc.Close()
Next
Output.Show("s:" & s)