【问题标题】:SEO: A whois server that work for .SE domains?SEO:适用于 .SE 域的 whois 服务器?
【发布时间】:2010-12-12 18:48:34
【问题描述】:

我正在开发一个小型域检查器,但无法让 .SE 工作:

public string Lookup(string domain, RecordType recordType, SeoToolsSettings.Tld tld)
{
    TcpClient tcp = new TcpClient();
    tcp.Connect(tld.WhoIsServer, 43);
    string strDomain = recordType.ToString() + " " + domain + "\r\n";
    byte[] bytDomain = Encoding.ASCII.GetBytes(strDomain.ToCharArray());
    Stream s = tcp.GetStream();
    s.Write(bytDomain, 0, strDomain.Length);
    StreamReader sr = new StreamReader(tcp.GetStream(), Encoding.ASCII);
    string strLine = "";
    StringBuilder builder = new StringBuilder();
    while (null != (strLine = sr.ReadLine()))
    {
        builder.AppendLine(strLine);
    }
    tcp.Close();
    if (tld.WhoIsDelayMs > 0) System.Threading.Thread.Sleep(tld.WhoIsDelayMs);
    return builder.ToString();
}

我已经尝试过 whois 服务器 whois.nic-se.se 和 whois.iis.se 我不断得到:

# Copyright (c) 1997- .SE (The Internet Infrastructure Foundation).
# All rights reserved.

# The information obtained through searches, or otherwise, is protected
# by the Swedish Copyright Act (1960:729) and international conventions.
# It is also subject to database protection according to the Swedish
# Copyright Act.

# Any use of this material to target advertising or
# similar activities is forbidden and will be prosecuted.
# If any of the information below is transferred to a third
# party, it must be done in its entirety. This server must
# not be used as a backend for a search engine.

# Result of search for registered domain names under
# the .SE top level domain.

# The data is in the UTF-8 character set and the result is
# printed with eight bits.

"domain google.se" not found.

编辑:

我已尝试更改为 UTF8,但没有其他结果。

当我尝试使用来自 sysinternals 的 whois 时,我得到了正确的结果,但我的代码却没有,甚至没有使用 SE.whois-servers.net。

/尼尔斯

【问题讨论】:

  • 您的代码是否适用于其他 TLD 的 whois 服务器?
  • 我在 Win7 上使用 Sysinternals whois google.se 得到正确的输出
  • 是的,我的代码适用于其他 TLD。我将 whois.internic.net 用于 .com 域,效果很好。

标签: c# whois


【解决方案1】:

嗯,在我的 Mac 上执行 whois google.se 时,我得到以下信息:

# Copyright (c) 1997- .SE (The Internet Infrastructure Foundation).
# All rights reserved.

# The information obtained through searches, or otherwise, is protected
# by the Swedish Copyright Act (1960:729) and international conventions.
# It is also subject to database protection according to the Swedish
# Copyright Act.

# Any use of this material to target advertising or
# similar activities is forbidden and will be prosecuted.
# If any of the information below is transferred to a third
# party, it must be done in its entirety. This server must
# not be used as a backend for a search engine.

# Result of search for registered domain names under
# the .SE top level domain.

# The data is in the UTF-8 character set and the result is
# printed with eight bits.

state:            active
domain:           google.se
holder:           googoo5855-00001
admin-c:          -
tech-c:           -
billing-c:        -
created:          2008-10-20
modified:         2010-09-18
expires:          2011-10-20
transferred:      2009-03-06
nserver:          ns1.google.com
nserver:          ns2.google.com
nserver:          ns3.google.com
nserver:          ns4.google.com
dnssec:           unsigned delegation
status:           ok
registrar:        MarkMonitor Inc

所以它可能只是你的代码。也许您必须以非 ASCII 编码(例如 UTF8)来执行请求?

【讨论】:

  • 嗯...将尝试使用其他编码...但是是否可以在 mac 上查看您使用的 whois 服务器?请注意,我已经将它用于带有 whois 服务器 whois.internic.net 的 .com 域。
【解决方案2】:

我终于解决了。

使用wireshark,我看到sysinternals的whois没有添加“DOMAIN”部分:

字符串 strDomain = recordType.ToString() + " " + domain + "\r\n";

(recordType.ToString == "DOMAIN").

所以当我删除它时,它起作用了!

【讨论】:

    【解决方案3】:

    不看你的代码为什么不:

    示例@http://balexandre.com/verifyDomain.aspx

    这会给你par.se

    IP Found:
    - 193.13.249.142
    
    Host name: 
    - parweb1.par.se
    Aliases: 
    none
    IP address list: 
    - 193.13.249.142
    

    如果你只是想要一个IP的RIPE信息,也可以使用我的页面进行测试

    http://balexandre.com/iplookup.aspx?ip={要测试的ip}


    按钮事件

    protected void btnCheck_Click(object sender, EventArgs e)
    {
        DomainCheck domain = new DomainCheck();
        string ip = domain.GetIPFromDomain(txtDomain.Text.Trim());
    
        litResponse.Text = String.Format(
                                "IP{0} Found:<br/> - <strong>{1}</strong><br/>{2}",
                                ip.Contains(",") ? "'s" : "",
                                ip.Replace(",", "<br/> - "), domain.VerifyIP(ip));
    }
    

    域校验码:

    public class DomainCheck
    {
        public DomainCheck() { }
    
        public string VerifyIP(string ipAddress)
        {
            if (String.IsNullOrEmpty(ipAddress))
                return "IP Address is invalid!";
    
            string r = "";
    
            if (ipAddress.Contains(","))
            {
                foreach (string ip in ipAddress.Split(','))
                    r += String.Format("<br/><br/>#### <em>Checking {0}</em>{1}", ip, CheckIPAddress(ip));
            }
            else
                r += CheckIPAddress(ipAddress);
    
            return r;
        }
        public string GetIPFromDomain(string hostname)
        {
            string r = "";
            IPAddress[] addresslist = Dns.GetHostAddresses(hostname);
    
            foreach (IPAddress theaddress in addresslist)
            {
                r += String.Format("{0},", theaddress.ToString());
            }
            return String.IsNullOrEmpty(r) ? null : r.TrimEnd(',');
        }
    
        private string CheckIPAddress(string ipAddress)
        {
            string r = "";
            try
            {
                IPAddress hostIPAddress = IPAddress.Parse(ipAddress);
                IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);
                // Get the IP address list that resolves to the host names contained in  
                // the Alias property. 
                IPAddress[] address = hostInfo.AddressList;
                // Get the alias names of the addresses in the IP address list. 
                String[] alias = hostInfo.Aliases;
                r += String.Format(
                        "<br/>Host name: <br/>- <strong>{0}</strong><br/>Aliases: ",
                        hostInfo.HostName);
    
                if (alias.Length == 0)
                    r += "<br/><em>none</em>";
                else
                    for (int index = 0; index < alias.Length; index++)
                        r += String.Format("<br/>- <strong>{0}</strong>", alias[index]);
    
                r += "<br/>IP address list: ";
                if (address.Length == 0)
                    r += "<br/><em>none</em>";
                else
                    for (int index = 0; index < address.Length; index++)
                        r += String.Format("<br/>- <strong>{0}</strong>", address[index]);
            }
            catch (SocketException e)
            {
                r = String.Format(
                        "SocketException caught!!!<br/>Source : {0}<br/>Message : {1}",
                        e.Source, e.Message);
            }
            catch (FormatException e)
            {
                r = String.Format(
                        "FormatException caught!!!<br/>Source : {0}<br/>Message : {1}",
                        e.Source, e.Message);
            }
            catch (ArgumentNullException e)
            {
                r = String.Format(
                        "ArgumentNullException caught!!!<br/>Source : {0}<br/>Message : {1}",
                        e.Source, e.Message);
            }
            catch (Exception e)
            {
                r = String.Format(
                        "Exception caught!!!<br/>Source : {0}<br/>Message : {1}",
                        e.Source, e.Message);
            }
            return r;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-23
      相关资源
      最近更新 更多