【问题标题】:Is there any way to query a whois server using webclient in vb.net?有没有办法在 vb.net 中使用 webclient 查询 whois 服务器?
【发布时间】:2013-10-29 06:06:00
【问题描述】:

http://www.anta.net/misc/telnet-troubleshooting/whois.shtml 表明我们可以使用 telnet 获取 whois 服务器

但是,webclient 使用 get 和 http 协议。

那么如何通过vb.net获取whois呢?

像 domainpunch 这样的软件可以获取大量的域信息。但是,他们不可能只查询 whois 服务器,因为其中大多数是速率限制的。

也许他们会查询大量的 whois 服务器。

或者怎么做?

【问题讨论】:

    标签: vb.net telnet whois


    【解决方案1】:

    一个简单的TcpClient 就可以了。 WhoIs 是一个非常简单的协议:您只需连接并发送查询,然后发送 \r\n

    示例:

    Private Sub Main()
        Dim data = System.Text.Encoding.ASCII.GetBytes("stackoverflow.com" & Microsoft.VisualBasic.vbCr & Microsoft.VisualBasic.vbLf)
        Using client = New TcpClient("whois.name.com", 43),
            stream = client.GetStream()
            stream.Write(data, 0, data.Length)
    
            data = New Byte(255) {}
            Dim responseData = String.Empty
            Dim read = stream.Read(data, 0, data.Length)
            While read > 0
                responseData = System.Text.Encoding.ASCII.GetString(data, 0, read)
                Console.Write(responseData)
                read = stream.Read(data, 0, data.Length)
            End While
        End Using
    End Sub
    

    输出:

    __   _                             ____                
    | \ | | __ _ _ __ ___   ___       / ___|___  _ __ ___  
    |  \| |/ _` | '_ ` _ \ / _ \     | |   / _ \| '_ ` _ \ 
    | |\  | (_| | | | | | |  __/  _  | |__| (_) | | | | | |
    |_| \_|\__,_|_| |_| |_|\___| (_)  \____\___/|_| |_| |_|
    On a first name basis with the rest of the world.
    
    
    Get your <a href="http://www.name.com">domains</a> at Name.com.
    
    
    Domain Name:     stackoverflow.com
    Registrar:       Name.com LLC
    
    Expiration Date: 2015-12-26 19:18:07
    Creation Date:   2003-12-26 19:18:07
    
    Name Servers:
      ns1.serverfault.com
      ns2.serverfault.com
    
    REGISTRANT CONTACT INFO
    Stack Exchange, Inc.
    Sysadmin Team
    1 Exchange Plaza
    Floor 26
    New York
    NY
    10006
    US
    Phone:         +1.2122328280
    Email Address: sysadmin-team@stackoverflow.com
    
    ADMINISTRATIVE CONTACT INFO
    Stack Exchange, Inc.
    Sysadmin Team
    1 Exchange Plaza
    Floor 26
    New York
    NY
    10006
    US
    Phone:         +1.2122328280
    Email Address: sysadmin-team@stackoverflow.com
    
    TECHNICAL CONTACT INFO
    Stack Exchange, Inc.
    Sysadmin Team
    1 Exchange Plaza
    Floor 26
    New York
    NY
    10006
    US
    Phone:         +1.2122328280
    Email Address: sysadmin-team@stackoverflow.com
    
    BILLING CONTACT INFO
    Stack Exchange, Inc.
    Sysadmin Team
    1 Exchange Plaza
    Floor 26
    New York
    NY
    10006
    US
    Phone:         +1.2122328280
    Email Address: sysadmin-team@stackoverflow.com
    
    Timestamp: 1383039360.9081
    
    The Data in the Name.com LLC WHOIS database is provided by Name.com LLC for information purposes, and to assist persons in obtaining information about or related to a domain name registration record.  Name.com LLC does not guarantee its accuracy.  By submitting a WHOIS query, you agree that you will use this Data only for lawful purposes and that, under no circumstances will you use this Data to:  (1) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via e-mail (spam); or (2) enable high volume, automated, electronic processes that apply to Name.com LLC (or its systems). Name.com LLC reserves the right to modify these terms at any time.  By submitting this query, you agree to abide by this policy.
    
    Cached on: 2013-10-29T03:36:00-06:00
    

    【讨论】:

    • 我们可以改用 webclient 或 webrequest 吗?
    • @JimThio 为什么? WebClient 使用 http,而不是 whois 协议。这就像要求使用 ftp 查询 http 资源或使用 ICMP 查询 ftp 资源。您当然可以使用WebClient 来查询whois 代理服务器,但是您依赖于单个网站及其对单个服务提供商的具体实现,因此您真的不应该这样做。一个简单的TcpClient 有什么问题?
    • 顺便说一句,您的解决方案不适用于域 google.com,我想知道为什么
    • @JimThio your solution doesn't work for domain google.com 是什么意思?
    • 通过 google.com,我得到了“NO DOMAIN (1)”和 vbLf 和“”和 vbLf 和“缓存于:2013-10-30T07:23:39-06:00”和 vbLf & "" 我几乎复制并粘贴了您的代码。
    猜你喜欢
    • 1970-01-01
    • 2016-03-24
    • 2021-03-02
    • 2020-02-08
    • 1970-01-01
    • 1970-01-01
    • 2012-01-10
    • 2023-03-30
    • 2020-12-02
    相关资源
    最近更新 更多