以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]HttpClient返回结果不正确  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=191774)

--  作者:洮沙
--  发布时间:2024/5/9 9:55:00
--  [求助]HttpClient返回结果不正确
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编辑过]

--  作者:有点蓝
--  发布时间:2024/5/9 10:20:00
--  
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)

--  作者:洮沙
--  发布时间:2024/5/9 10:25:00
--