Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共3 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]HttpClient返回结果不正确

1楼
洮沙 发表于:2024/5/9 9:55: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)
    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编辑过]
2楼
有点蓝 发表于: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)
3楼
洮沙 发表于:2024/5/9 10:25:00
共3 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02148 s, 2 queries.