http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 24338|回复: 21

[接口] C#实现WhoIs查询

[复制链接]
发表于 2012-11-9 16:09:19 | 显示全部楼层 |阅读模式
简介

   也许还有很多朋友不知Who Is是什么东西?是作什么 的,有什么用处,其实我也是刚刚接触这一块,拿出来跟大家分享一下,也希望能得到高手的指点。
Who Is 应该说是站长工具的一种,像51.la,aizhan.com上都有这样的工具,他的真正作用就是输入域名可以查询到这个域名的详细信息,比如到期时间,注册时间,更新时间,联系人,注册商,联系电话 ,QQ等 等。
应该是这样讲,一般站长或者IDC行业用的相当的多。
像我们自己也可以没事查查,自己喜欢的域名是否已被注册或是什么时候到期。当然你也可以查询一下到期时间和联系方式进行高价回收。
    whois查询,其实不同的域名类型都有相就的终极Whois服务器存在,大约有200多种吧,这个也不是很难找我们可以在Google上找到,但从这上面只能查到一些简单的信息,如果要查询更详细 的域名信息的话,就要从他所在的Whois服务器查询了,所以我们的程序应该是分两步走的,
第一步是查询终级WhoIS服务器。
第二步根据上面提供的所在Whois服务器然后再进行,进一步的详细查询 ,这时把两个结果合到一起才能得到我们想要的详细信息。
实现流程

第一步:我们先来写一个用来查询Whois服务器信息的方法,我们都知道查询域名的Whois信息应该是访问所在服务器的43端口,只要我们使用程序把要查询的域名通过whois服务器的43端口传入就可以接收到返回的Whois信息了,有了这个提示,下面应该不难了吧,一起看下代码吧
[C#] 纯文本查看 复制代码
/// <summary>
        /// 查询域名的 WhoIs 信息 终端查询方式
        /// </summary>
        /// <param name="domain">要查询的域名</param>
        /// <param name="server">WhoIs 服务器地址</param>
        /// <param name="port">WhoIs 服务器端口</param>
        /// <returns>
        /// 执行成功: 返回详细的WhoIs信息
        /// 执行失败:返回相就的异常或是错误信息
        /// </returns>
        public static string BaseType(string domain, string server, int port = 43)
        {
            // 连接域名 Whois 查询服务器
            TcpClient tcp = new TcpClient();
            //return string
            string returnstr = "String Error";
            try
            {
                tcp.Connect(server, port);
            }
            catch (SocketException e)
            {
                returnstr = "连接 Whois 服务器失败 : " + e.Message.Trim();
            }

            // 向域名 Whois 查询服务器发送查询的域名
            try
            {
                //构造发送的字符串
                domain += "\r\n";
                Byte[] DomainBytes = System.Text.Encoding.ASCII.GetBytes(domain.ToCharArray());

                // 将域名发送到域名 Whois 查询服务器
                Stream WhoisStream = tcp.GetStream();
                WhoisStream.Write(DomainBytes, 0, domain.Length);
                StreamReader WhoisStreamReader = new StreamReader(WhoisStream, System.Text.Encoding.UTF8);
                returnstr = WhoisStreamReader.ReadToEnd().Trim();
            }
            catch (Exception e)
            {
                returnstr = "域名 '" + domain + "' 的 Whois 查询失败 : " + e.Message.Trim();
            }
            finally
            {
                tcp.Close();
            }
            return returnstr;
        }

端口我是默认的,WhoIs 服务器地址是怎么得到的呢?
第二步得到终级Whois服务器地址,这个可以从网上下载 一个列表,在做列表之前咱们先来创建两家Item吧
[C#] 纯文本查看 复制代码
  /// <summary>
    /// 表示一个顶级域的 WhoIs 服务器地址
    /// </summary>
    public class WhoIsServerItem
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="tld">顶级域</param>
        /// <param name="server">WhoIs 服务器地址</param>
        public WhoIsServerItem(string tld, string server)
        {
            this.Tld = tld;
            this.Server = server;
        }

        /// <summary>
        /// 顶级域
        /// </summary>
        public string Tld { get; set; }

        /// <summary>
        /// WhoIs 服务器地址
        /// </summary>
        public string Server { get; set; }
    }

    /// <summary>
    /// 表示一个顶级域的 WhoIs 服务器“没有找到”字符串的数据
    /// </summary>
    public class WhoIsServerNotFoundItem
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="server">WhoIs 服务器地址</param>
        /// <param name="notFoundString">表示“没有找到”的字符串</param>
        public WhoIsServerNotFoundItem(string server, string notFoundString)
        {
            this.Server = server;
            this.NotFoundString = notFoundString;
        }

        /// <summary>
        /// WhoIs 服务器地址
        /// </summary>
        public string Server { get; set; }

        /// <summary>
        /// 表示“没有找到”的字符串
        /// </summary>
        public string NotFoundString { get; set; }
    }

大家根据注释就应该能明白是做什么用的吧,
还有两个方法 也是必须要的,它们主要是为了验证时使用的,一起来看一下吧
[C#] 纯文本查看 复制代码
  /// <summary>
        /// 根据域名获取域名的 WhoIs 服务器地址
        /// </summary>
        /// <param name="domain">要查询的域名</param>
        /// <returns>
        /// 执行成功: 返回传入域名对就的终级WhoIs服务器
        /// 执行失败:返回"String Error"
        /// </returns>
        private static string getWhoIsServer(string domain)
        {
            string[] arr = domain.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
            string tld = arr[arr.Length - 1];

            var query = (from x in WhoIs_InfoServers
                         where x.Tld == tld
                         select x).FirstOrDefault();
            return query == null ? "String Error" : query.Server;
        }

        /// <summary>
        /// 获取 WhoIs 服务器“域名不存在”信息的表示字符串
        /// </summary>
        /// <param name="server">WhoIs 服务器名称</param>
        /// <returns>
        /// 执行成功: 根据传入的服务器返回可能出现的异常字符串
        /// 执行失败:返回"No match"
        /// </returns>
        private static string getWhoIsServerNotFoundString(string server)
        {
            var query = (from x in Whois_NotFoundString
                         where x.Server == server
                         select x).FirstOrDefault();
            return query == null ? "No match" : query.NotFoundString;
        }

列表的话我一会儿会在最下面给出
第三步,实现第一步的简单信息查询
我们根据第一步提供的方法
BaseType一起来查询一个域名试试,咱们就以cnblogs.com为例子
先看一下代码
[C#] 纯文本查看 复制代码
/// <summary>
        /// 查询域名的 WhoIs 信息
        /// </summary>
        /// <param name="domain">要查询的域名</param>
        /// <returns>
        /// 执行成功: 返回详细的WhoIs信息
        /// 执行失败:返回相就的异常或是错误信息
        /// </returns>
        public static string WhoIs(string domain)
        {
            return WhoIs(domain, getWhoIsServer(domain));
        }

        /// <summary>
        /// 查询域名的 WhoIs 信息
        /// </summary>
        /// <param name="domain">要查询的域名</param>
        /// <param name="server">WhoIs 服务器地址</param>
        /// <returns>
        /// 执行成功: 返回详细的WhoIs信息
        /// 执行失败:返回相就的异常或是错误信息
        /// </returns>
        public static string WhoIs(string domain, string server)
        {

           return  WhoIsQueryMain.BaseType(domain, server, 43);
        }

执行后的结果如下
  1. View Code

  2. Whois Server Version 2.0

  3. Domain names in the .com and .net domains can now be registered
  4. with many different competing registrars. Go to http://www.internic.net
  5. for detailed information.

  6.    Domain Name: CNBLOGS.COM
  7.    Registrar: 35 TECHNOLOGY CO., LTD
  8.    Whois Server: whois.35.com
  9.    Referral URL: http://www.35.com
  10.    Name Server: NS1.HJDNS.NET
  11.    Name Server: NS2.HJDNS.NET
  12.    Status: clientDeleteProhibited
  13.    Status: clientTransferProhibited
  14.    Updated Date: 30-may-2011
  15.    Creation Date: 11-nov-2003
  16.    Expiration Date: 11-nov-2016

  17. >>> Last update of whois database: Fri, 19 Aug 2011 02:46:18 UTC <<<

  18. NOTICE: The expiration date displayed in this record is the date the
  19. registrar's sponsorship of the domain name registration in the registry is
  20. currently set to expire. This date does not necessarily reflect the expiration
  21. date of the domain name registrant's agreement with the sponsoring
  22. registrar.  Users may consult the sponsoring registrar's Whois database to
  23. view the registrar's reported date of expiration for this registration.

  24. TERMS OF USE: You are not authorized to access or query our Whois
  25. database through the use of electronic processes that are high-volume and
  26. automated except as reasonably necessary to register domain names or
  27. modify existing registrations; the Data in VeriSign Global Registry
  28. Services' ("VeriSign") Whois database is provided by VeriSign for
  29. information purposes only, and to assist persons in obtaining information
  30. about or related to a domain name registration record. VeriSign does not
  31. guarantee its accuracy. By submitting a Whois query, you agree to abide
  32. by the following terms of use: You agree that you may use this Data only
  33. for lawful purposes and that under no circumstances will you use this Data
  34. to: (1) allow, enable, or otherwise support the transmission of mass
  35. unsolicited, commercial advertising or solicitations via e-mail, telephone,
  36. or facsimile; or (2) enable high volume, automated, electronic processes
  37. that apply to VeriSign (or its computer systems). The compilation,
  38. repackaging, dissemination or other use of this Data is expressly
  39. prohibited without the prior written consent of VeriSign. You agree not to
  40. use electronic processes that are automated and high-volume to access or
  41. query the Whois database except as reasonably necessary to register
  42. domain names or modify existing registrations. VeriSign reserves the right
  43. to restrict your access to the Whois database in its sole discretion to ensure
  44. operational stability.  VeriSign may restrict or terminate your access to the
  45. Whois database for failure to abide by these terms of use. VeriSign
  46. reserves the right to modify these terms at any time.

  47. The Registry database contains ONLY .COM, .NET, .EDU domains and
  48. Registrars.The Data in OnlineNIC's WHOIS database is provided by OnlineNIC
  49.     for information purposes, and to assist persons in obtaining
  50.     information about or related to a domain name registration record.
  51.     OnlineNIC does not guarantee its accuracy. By starting a WHOIS
  52.     query, you agree that you will use this Data only for lawful
  53.     purposes and that, under no circumstances will you use this Data
  54.     to:
  55.     (1)allow, enable, or otherwise support the transmission of mass
  56.     unsolicited,commercial advertising or solicitations via e-mail(spam).
  57.     (2)enable high volume,automated, electronic processes that apply
  58.     to OnlineNIC Inc.(or its systems).

  59.     OnlineNIC reserves the right to modify these terms at any time.
  60.     By starting this query, you agree to abide by this policy.


  61. Registrant:
  62.      du yong dudu.yz@gmail.com +86.02158950900
  63.      Shanghai Yucheng Information Technology Co. Ltd.
  64.      Room 7002,Puruan Building,No.2 Boyun Road,Pudong New Area
  65.      Shanghai,Shanghai,CN 201203


  66. Domain Name:cnblogs.com
  67. Record last updated at 2011-08-18 00:12:04
  68. Record created on 2003/11/11
  69. Record expired on 2016/11/11


  70. Domain servers in listed order:
  71.      ns1.hjdns.net      ns2.hjdns.net

  72. Administrator:
  73.      name:(du yong)
  74.     Email:(dudu.yz@gmail.com) tel-- +86.02158950900
  75.      Shanghai Yucheng Information Technology Co. Ltd.
  76.      Room 7002,Puruan Building,No.2 Boyun Road,Pudong New Area
  77. \r
  78. t Shanghai
  79. Shanghai,
  80. CN

  81. zipcode:201203

  82. Technical Contactor:
  83.      name:(du yong)
  84.     Email:(dudu.yz@gmail.com) tel-- +86.02158950900
  85.      Shanghai Yucheng Information Technology Co. Ltd.
  86.      Room 7002,Puruan Building,No.2 Boyun Road,Pudong New Area
  87. \r
  88. t Shanghai
  89. Shanghai,
  90. CN

  91. zipcode:201203

  92. Billing Contactor:
  93.      name:(du yong)
  94.     Email:(dudu.yz@gmail.com) tel-- +86.02158950900
  95.      Shanghai Yucheng Information Technology Co. Ltd.
  96.      Room 7002,Puruan Building,No.2 Boyun Road,Pudong New Area
  97. \r
  98. t Shanghai
  99. Shanghai,
  100. CN

  101. zipcode:201203
复制代码
其实在这里我们能清楚的看到它的Whois服务器应该是
   Whois Server: whois.35.com
接下一来我们只要用相同的方法再去请求一下这个地址就能得到真正详细的域名信息了。
这个我就不验证了,大家自己动手做下测试 吧
其实真正要怎么样实现才更好,才更高效,我目前还是不很清楚,如果以后有更好的方法 一定跟大家分享,如果那位高手有更好的方式,希望可以交流一下经验。
下面我把列表发上来大家参考一下吧
[C#] 纯文本查看 复制代码
 #region 静态数据
        /// <summary>
        /// WhoIs 信息服务器
        /// </summary>
        public static readonly WhoIsServerItem[] WhoIs_InfoServers =
        {
            new WhoIsServerItem("com", "whois.internic.net"),
            new WhoIsServerItem("net", "whois.internic.net"),
            new WhoIsServerItem("org", "whois.pir.org"),
            new WhoIsServerItem("gov", "whois.internic.net"),
            new WhoIsServerItem("bz", "whois.belizenic.bz"),
            new WhoIsServerItem("biz", "whois.neulevel.biz"),
            new WhoIsServerItem("info", "whois.afilias.info"),
            new WhoIsServerItem("ws", "whois.website.ws"),
            new WhoIsServerItem("co.uk", "whois.nic.uk"),
            new WhoIsServerItem("org.uk", "whois.nic.uk"),
            new WhoIsServerItem("ltd.uk", "whois.nic.uk"),
            new WhoIsServerItem("plc.uk", "whois.nic.uk"),
            new WhoIsServerItem("edu", "whois.internic.net"),
            new WhoIsServerItem("mil", "whois.internic.net"),
            new WhoIsServerItem("br.com", "whois.centralnic.com"),
            new WhoIsServerItem("cn.com", "whois.centralnic.com"),
            new WhoIsServerItem("eu.com", "whois.centralnic.com"),
            new WhoIsServerItem("hu.com", "whois.centralnic.com"),
            new WhoIsServerItem("no.com", "whois.centralnic.com"),
            new WhoIsServerItem("qc.com", "whois.centralnic.com"),
            new WhoIsServerItem("sa.com", "whois.centralnic.com"),
            new WhoIsServerItem("se.com", "whois.centralnic.com"),
            new WhoIsServerItem("se.net", "whois.centralnic.com"),
            new WhoIsServerItem("us.com", "whois.centralnic.com"),
            new WhoIsServerItem("uy.com", "whois.centralnic.com"),
            new WhoIsServerItem("za.com", "whois.centralnic.com"),
            new WhoIsServerItem("ac", "whois.ripe.net"),
            new WhoIsServerItem("ac.ac", "whois.ripe.net"),
            new WhoIsServerItem("co.ac", "whois.ripe.net"),
            new WhoIsServerItem("gv.ac", "whois.ripe.net"),
            new WhoIsServerItem("or.ac", "whois.ripe.net"),
            new WhoIsServerItem("af", "whois.netnames.net"),
            new WhoIsServerItem("am", "whois.nic.am"),
            new WhoIsServerItem("as", "whois.nic.as"),
            new WhoIsServerItem("at", "whois.nic.at"),
            new WhoIsServerItem("ac.at", "whois.nic.at"),
            new WhoIsServerItem("co.at", "whois.nic.at"),
            new WhoIsServerItem("gv.at", "whois.nic.at"),
            new WhoIsServerItem("or.at", "whois.nic.at"),
            new WhoIsServerItem("asn.au", "whois.aunic.net"),
            new WhoIsServerItem("com.au", "whois.aunic.net"),
            new WhoIsServerItem("edu.au", "whois.aunic.net"),
            new WhoIsServerItem("org.au", "whois.aunic.net"),
            new WhoIsServerItem("net.au", "whois.aunic.net"),
            new WhoIsServerItem("be", "whois.ripe.net"),
            new WhoIsServerItem("ac.be", "whois.ripe.net"),
            new WhoIsServerItem("br", "whois.nic.br"),
            new WhoIsServerItem("adm.br", "whois.nic.br"),
            new WhoIsServerItem("adv.br", "whois.nic.br"),
            new WhoIsServerItem("am.br", "whois.nic.br"),
            new WhoIsServerItem("arq.br", "whois.nic.br"),
            new WhoIsServerItem("art.br", "whois.nic.br"),
            new WhoIsServerItem("bio.br", "whois.nic.br"),
            new WhoIsServerItem("cng.br", "whois.nic.br"),
            new WhoIsServerItem("cnt.br", "whois.nic.br"),
            new WhoIsServerItem("com.br", "whois.nic.br"),
            new WhoIsServerItem("ecn.br", "whois.nic.br"),
            new WhoIsServerItem("eng.br", "whois.nic.br"),
            new WhoIsServerItem("esp.br", "whois.nic.br"),
            new WhoIsServerItem("etc.br", "whois.nic.br"),
            new WhoIsServerItem("eti.br", "whois.nic.br"),
            new WhoIsServerItem("fm.br", "whois.nic.br"),
            new WhoIsServerItem("fot.br", "whois.nic.br"),
            new WhoIsServerItem("fst.br", "whois.nic.br"),
            new WhoIsServerItem("g12.br", "whois.nic.br"),
            new WhoIsServerItem("gov.br", "whois.nic.br"),
            new WhoIsServerItem("ind.br", "whois.nic.br"),
            new WhoIsServerItem("inf.br", "whois.nic.br"),
            new WhoIsServerItem("jor.br", "whois.nic.br"),
            new WhoIsServerItem("lel.br", "whois.nic.br"),
            new WhoIsServerItem("med.br", "whois.nic.br"),
            new WhoIsServerItem("mil.br", "whois.nic.br"),
            new WhoIsServerItem("net.br", "whois.nic.br"),
            new WhoIsServerItem("nom.br", "whois.nic.br"),
            new WhoIsServerItem("ntr.br", "whois.nic.br"),
            new WhoIsServerItem("odo.br", "whois.nic.br"),
            new WhoIsServerItem("org.br", "whois.nic.br"),
            new WhoIsServerItem("ppg.br", "whois.nic.br"),
            new WhoIsServerItem("pro.br", "whois.nic.br"),
            new WhoIsServerItem("psc.br", "whois.nic.br"),
            new WhoIsServerItem("psi.br", "whois.nic.br"),
            new WhoIsServerItem("rec.br", "whois.nic.br"),
            new WhoIsServerItem("slg.br", "whois.nic.br"),
            new WhoIsServerItem("tmp.br", "whois.nic.br"),
            new WhoIsServerItem("tur.br", "whois.nic.br"),
            new WhoIsServerItem("tv.br", "whois.nic.br"),
            new WhoIsServerItem("vet.br", "whois.nic.br"),
            new WhoIsServerItem("zlg.br", "whois.nic.br"),
            new WhoIsServerItem("ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("ab.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("bc.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("mb.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("nb.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("nf.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("ns.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("nt.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("on.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("pe.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("qc.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("sk.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("yk.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("cc", "whois.nic.cc"),
            new WhoIsServerItem("cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("ac.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("com.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("edu.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("gov.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("net.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("org.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("bj.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("sh.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("tj.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("cq.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("he.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("nm.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("ln.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("jl.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("hl.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("js.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("zj.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("ah.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("hb.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("hn.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("gd.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("gx.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("hi.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("sc.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("gz.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("yn.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("xz.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("sn.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("gs.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("qh.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("nx.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("xj.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("tw.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("hk.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("mo.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("cx", "whois.cx.net"),
            new WhoIsServerItem("cz", "whois.ripe.net"),
            new WhoIsServerItem("de", "whois.nic.de"),
            new WhoIsServerItem("dk", "whois.ripe.net"),
            new WhoIsServerItem("fo", "whois.ripe.net"),
            new WhoIsServerItem("com.ec", "whois.lac.net"),
            new WhoIsServerItem("org.ec", "whois.lac.net"),
            new WhoIsServerItem("net.ec", "whois.lac.net"),
            new WhoIsServerItem("mil.ec", "whois.lac.net"),
            new WhoIsServerItem("fin.ec", "whois.lac.net"),
            new WhoIsServerItem("med.ec", "whois.lac.net"),
            new WhoIsServerItem("gov.ec", "whois.lac.net"),
            new WhoIsServerItem("fr", "whois.nic.fr"),
            new WhoIsServerItem("tm.fr", "whois.nic.fr"),
            new WhoIsServerItem("com.fr", "whois.nic.fr"),
            new WhoIsServerItem("asso.fr", "whois.nic.fr"),
            new WhoIsServerItem("presse.fr", "whois.nic.fr"),
            new WhoIsServerItem("gf", "whois.nplus.gf"),
            new WhoIsServerItem("gs", "whois.adamsnames.tc"),
            new WhoIsServerItem("co.il", "whois.ripe.net"),
            new WhoIsServerItem("org.il", "whois.ripe.net"),
            new WhoIsServerItem("net.il", "whois.ripe.net"),
            new WhoIsServerItem("ac.il", "whois.ripe.net"),
            new WhoIsServerItem("k12.il", "whois.ripe.net"),
            new WhoIsServerItem("gov.il", "whois.ripe.net"),
            new WhoIsServerItem("muni.il", "whois.ripe.net"),
            new WhoIsServerItem("ac.in", "whois.iisc.ernet.in"),
            new WhoIsServerItem("co.in", "whois.iisc.ernet.in"),
            new WhoIsServerItem("ernet.in", "whois.iisc.ernet.in"),
            new WhoIsServerItem("gov.in", "whois.iisc.ernet.in"),
            new WhoIsServerItem("net.in", "whois.iisc.ernet.in"),
            new WhoIsServerItem("res.in", "whois.iisc.ernet.in"),
            new WhoIsServerItem("is", "whois.ripe.net"),
            new WhoIsServerItem("it", "whois.ripe.net"),
            new WhoIsServerItem("ac.jp", "whois.nic.ad.jp"),
            new WhoIsServerItem("co.jp", "whois.nic.ad.jp"),
            new WhoIsServerItem("go.jp", "whois.nic.ad.jp"),
            new WhoIsServerItem("or.jp", "whois.nic.ad.jp"),
            new WhoIsServerItem("ne.jp", "whois.nic.ad.jp"),
            new WhoIsServerItem("ac.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("co.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("go.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("ne.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("nm.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("or.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("re.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("li", "whois.nic.li"),
            new WhoIsServerItem("lt", "whois.ripe.net"),
            new WhoIsServerItem("lu", "whois.ripe.net"),
            new WhoIsServerItem("asso.mc", "whois.ripe.net"),
            new WhoIsServerItem("tm.mc", "whois.ripe.net"),
            new WhoIsServerItem("com.mm", "whois.nic.mm"),
            new WhoIsServerItem("org.mm", "whois.nic.mm"),
            new WhoIsServerItem("net.mm", "whois.nic.mm"),
            new WhoIsServerItem("edu.mm", "whois.nic.mm"),
            new WhoIsServerItem("gov.mm", "whois.nic.mm"),
            new WhoIsServerItem("ms", "whois.adamsnames.tc"),
            new WhoIsServerItem("mx", "whois.nic.mx"),
            new WhoIsServerItem("com.mx", "whois.nic.mx"),
            new WhoIsServerItem("org.mx", "whois.nic.mx"),
            new WhoIsServerItem("net.mx", "whois.nic.mx"),
            new WhoIsServerItem("edu.mx", "whois.nic.mx"),
            new WhoIsServerItem("gov.mx", "whois.nic.mx"),
            new WhoIsServerItem("nl", "whois.domain-registry.nl"),
            new WhoIsServerItem("no", "whois.norid.no"),
            new WhoIsServerItem("nu", "whois.nic.nu"),
            new WhoIsServerItem("pl", "whois.ripe.net"),
            new WhoIsServerItem("com.pl", "whois.ripe.net"),
            new WhoIsServerItem("net.pl", "whois.ripe.net"),
            new WhoIsServerItem("org.pl", "whois.ripe.net"),
            new WhoIsServerItem("pt", "whois.ripe.net"),
            new WhoIsServerItem("com.ro", "whois.ripe.net"),
            new WhoIsServerItem("org.ro", "whois.ripe.net"),
            new WhoIsServerItem("store.ro", "whois.ripe.net"),
            new WhoIsServerItem("tm.ro", "whois.ripe.net"),
            new WhoIsServerItem("firm.ro", "whois.ripe.net"),
            new WhoIsServerItem("www.ro", "whois.ripe.net"),
            new WhoIsServerItem("arts.ro", "whois.ripe.net"),
            new WhoIsServerItem("rec.ro", "whois.ripe.net"),
            new WhoIsServerItem("info.ro", "whois.ripe.net"),
            new WhoIsServerItem("nom.ro", "whois.ripe.net"),
            new WhoIsServerItem("nt.ro", "whois.ripe.net"),
            new WhoIsServerItem("ru", "whois.ripn.net"),
            new WhoIsServerItem("com.ru", "whois.ripn.net"),
            new WhoIsServerItem("net.ru", "whois.ripn.net"),
            new WhoIsServerItem("org.ru", "whois.ripn.net"),
            new WhoIsServerItem("se", "whois.nic-se.se"),
            new WhoIsServerItem("si", "whois.arnes.si"),
            new WhoIsServerItem("com.sg", "whois.nic.net.sg"),
            new WhoIsServerItem("org.sg", "whois.nic.net.sg"),
            new WhoIsServerItem("net.sg", "whois.nic.net.sg"),
            new WhoIsServerItem("gov.sg", "whois.nic.net.sg"),
            new WhoIsServerItem("sk", "whois.ripe.net"),
            new WhoIsServerItem("st", "whois.nic.st"),
            new WhoIsServerItem("tc", "whois.adamsnames.tc"),
            new WhoIsServerItem("tf", "whois.adamsnames.tc"),
            new WhoIsServerItem("ac.th", "whois.thnic.net"),
            new WhoIsServerItem("co.th", "whois.thnic.net"),
            new WhoIsServerItem("go.th", "whois.thnic.net"),
            new WhoIsServerItem("mi.th", "whois.thnic.net"),
            new WhoIsServerItem("net.th", "whois.thnic.net"),
            new WhoIsServerItem("or.th", "whois.thnic.net"),
            new WhoIsServerItem("tj", "whois.nic.tj"),
            new WhoIsServerItem("tm", "whois.nic.tm"),
            new WhoIsServerItem("to", "monarch.tonic.to"),
            new WhoIsServerItem("bbs.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("com.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("edu.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("gov.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("k12.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("mil.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("net.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("org.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("com.tw", "whois.twnic.net"),
            new WhoIsServerItem("net.tw", "whois.twnic.net"),
            new WhoIsServerItem("org.tw", "whois.twnic.net"),
            new WhoIsServerItem("ac.uk", "whois.ja.net"),
            new WhoIsServerItem("uk.co", "whois.uk.co"),
            new WhoIsServerItem("uk.com", "whois.nomination.net"),
            new WhoIsServerItem("uk.net", "whois.nomination.net"),
            new WhoIsServerItem("gb.com", "whois.nomination.net"),
            new WhoIsServerItem("gb.net", "whois.nomination.net"),
            new WhoIsServerItem("vg", "whois.adamsnames.tc"),
            new WhoIsServerItem("ac.za", "whois.co.za"),
            new WhoIsServerItem("alt.za", "whois.co.za"),
            new WhoIsServerItem("co.za", "whois.co.za"),
            new WhoIsServerItem("edu.za", "whois.co.za"),
            new WhoIsServerItem("gov.za", "whois.co.za"),
            new WhoIsServerItem("mil.za", "whois.co.za"),
            new WhoIsServerItem("net.za", "whois.co.za"),
            new WhoIsServerItem("ngo.za", "whois.co.za"),
            new WhoIsServerItem("nom.za", "whois.co.za"),
            new WhoIsServerItem("org.za", "whois.co.za"),
            new WhoIsServerItem("school.za", "whois.co.za"),
            new WhoIsServerItem("tm.za", "whois.co.za"),
            new WhoIsServerItem("web.za", "whois.co.za"),
            new WhoIsServerItem("sh", "whois.nic.sh"),
            new WhoIsServerItem("kz", "whois.domain.kz")
        };

        /// <summary>
        /// WhoIs 信息服务器表示“没有找到”的字符串
        /// </summary>
        public static readonly WhoIsServerNotFoundItem[] Whois_NotFoundString =
        {
            new WhoIsServerNotFoundItem("whois.internic.net", "No match"),
            new WhoIsServerNotFoundItem("whois.neulevel.biz", "Not found"),
            new WhoIsServerNotFoundItem("whois.afilias.info", "NOT FOUND"),
            new WhoIsServerNotFoundItem("whois.belizenic.bz", "No match for"),
            new WhoIsServerNotFoundItem("whois.website.ws", "No match for"),
            new WhoIsServerNotFoundItem("whois.nic.uk", "No match"),
            new WhoIsServerNotFoundItem("whois.bulkregister.com", "Not found"),
            new WhoIsServerNotFoundItem("whois.centralnic.com", "No match"),
            new WhoIsServerNotFoundItem("whois.ripe.net", "No entries found"),
            new WhoIsServerNotFoundItem("whois.netnames.net", "No Match"),
            new WhoIsServerNotFoundItem("whois.nic.am", "No information available"),
            new WhoIsServerNotFoundItem("whois.nic.as", "Domain Not Found"),
            new WhoIsServerNotFoundItem("whois.nic.at", "No entries found"),
            new WhoIsServerNotFoundItem("whois.aunic.net", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nic.br", "No match for"),
            new WhoIsServerNotFoundItem("whois.cdnnet.ca", "Not found"),
            new WhoIsServerNotFoundItem("whois.nic.cc", "No match"),
            new WhoIsServerNotFoundItem("whois.cnnic.net.cn", "No entries"),
            new WhoIsServerNotFoundItem("snail.cnnic.net.cn", "No entries"),
            new WhoIsServerNotFoundItem("whois.cx.net", "No match for"),
            new WhoIsServerNotFoundItem("whois.co.za", "No information available"),
            new WhoIsServerNotFoundItem("whois.twnic.net", "No Records Found"),
            new WhoIsServerNotFoundItem("whois.metu.edu.tr", "Not found in database"),
            new WhoIsServerNotFoundItem("whois.adamsnames.tc", "is not registered"),
            new WhoIsServerNotFoundItem("whois.ja.net", "Sorry - no"),
            new WhoIsServerNotFoundItem("whois.nomination.net", "No match for"),
            new WhoIsServerNotFoundItem("whoic.thnic.net", "No entries"),
            new WhoIsServerNotFoundItem("monarch.tonic.to", "Not found"),
            new WhoIsServerNotFoundItem("whois.nic.tm", "No match"),
            new WhoIsServerNotFoundItem("whois.nic.tj", "No match"),
            new WhoIsServerNotFoundItem("whois.nic.st", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nic.net.sg", "NO entry found"),
            new WhoIsServerNotFoundItem("whois.arnes.si", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nic-se.se", "No data found"),
            new WhoIsServerNotFoundItem("whois.ripn.net", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nic.nu", "Match for"),
            new WhoIsServerNotFoundItem("whois.norid.no", "no matches"),
            new WhoIsServerNotFoundItem("whois.domain-registry.nl", "not a registered domain"),
            new WhoIsServerNotFoundItem("whois.nic.mx", "Referencias de Organization No Encontradas"),
            new WhoIsServerNotFoundItem("whois.nic.mm", "No domains matched"),
            new WhoIsServerNotFoundItem("whois.net.au", "AUNIC -T domain"),
            new WhoIsServerNotFoundItem("whois.nic.bt", "shrubbery.com"),
            new WhoIsServerNotFoundItem("whois.cdnnet.ca", "Not found"),
            new WhoIsServerNotFoundItem("whois.nic.ch", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nic.cx", "No match for"),
            new WhoIsServerNotFoundItem("whois.nic.de", "No entries found"),
            new WhoIsServerNotFoundItem("whois.lac.net", "No match found"),
            new WhoIsServerNotFoundItem("whois.nic.fr", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nplus.gf", "not found in our database"),
            new WhoIsServerNotFoundItem("whois.iisc.ernet.in", "no entries found"),
            new WhoIsServerNotFoundItem("whois.nic.ad.jp", "No match"),
            new WhoIsServerNotFoundItem("whois.nic.or.kr", "is not registered"),
            new WhoIsServerNotFoundItem("whois.nic.li", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nic.mm", "No domains matched"),
            new WhoIsServerNotFoundItem("whois.norid.no", "no matches"),
            new WhoIsServerNotFoundItem("whois.nic-se.se", "No data found"),
            new WhoIsServerNotFoundItem("monarch.tonic.tj", "Not found"),
            new WhoIsServerNotFoundItem("whois.uk.co", "NO MATCH"),
            new WhoIsServerNotFoundItem("whois.nic.sh", "No match"),
            new WhoIsServerNotFoundItem("whois.domain.kz", "No entries found"),
            new WhoIsServerNotFoundItem("whois.crsnic.net", "No match for")
        };
        #endregion

Whois查询,要分两步,第一步是根据域名后缀,去顶级Whois服务服查询,如果是直接在顶级服务器上存储 的则返回详细信息,如果不是的话就返回正直在Whois服务器
,然后第二步去真正的Whois服务器去查询,看下面的方法
[C#] 纯文本查看 复制代码
/*
 * 更新时间 :2011-08-20 14:20
 * 更 新 人 :苏飞
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.IO;
using System.Text.RegularExpressions;
namespace OutFunction
{
    /// <summary>
    /// 为WhoIs查询提供方法
    /// </summary>
    public class WhoIsQuery
    {
        #region 静态数据
        /// <summary>
        /// WhoIs 信息服务器
        /// </summary>
        public static readonly WhoIsServerItem[] WhoIs_InfoServers =
        {
            new WhoIsServerItem("com", "whois.internic.net,whois.markmonitor.com"),
            new WhoIsServerItem("net", "whois.internic.net"),
            new WhoIsServerItem("la", "whois.nic.la"),//需要修改不正常
            new WhoIsServerItem("org", "whois.pir.org"),
            new WhoIsServerItem("gov", "whois.internic.net"),
            new WhoIsServerItem("bz", "whois.belizenic.bz"),
            new WhoIsServerItem("biz", "whois.neulevel.biz"),
            new WhoIsServerItem("info", "whois.afilias.info"),
            new WhoIsServerItem("ws", "whois.website.ws"),
            new WhoIsServerItem("co.uk", "whois.nic.uk"),
            new WhoIsServerItem("org.uk", "whois.nic.uk"),
            new WhoIsServerItem("ltd.uk", "whois.nic.uk"),
            new WhoIsServerItem("plc.uk", "whois.nic.uk"),
            new WhoIsServerItem("edu", "whois.internic.net"),
            new WhoIsServerItem("mil", "whois.internic.net"),
            new WhoIsServerItem("br.com", "whois.centralnic.com"),
            new WhoIsServerItem("cn.com", "whois.centralnic.com"),
            new WhoIsServerItem("eu.com", "whois.centralnic.com"),
            new WhoIsServerItem("hu.com", "whois.centralnic.com"),
            new WhoIsServerItem("no.com", "whois.centralnic.com"),
            new WhoIsServerItem("qc.com", "whois.centralnic.com"),
            new WhoIsServerItem("sa.com", "whois.centralnic.com"),
            new WhoIsServerItem("se.com", "whois.centralnic.com"),
            new WhoIsServerItem("se.net", "whois.centralnic.com"),
            new WhoIsServerItem("us.com", "whois.centralnic.com"),
            new WhoIsServerItem("uy.com", "whois.centralnic.com"),
            new WhoIsServerItem("za.com", "whois.centralnic.com"),
            new WhoIsServerItem("ac", "whois.ripe.net"),
            new WhoIsServerItem("ac.ac", "whois.ripe.net"),
            new WhoIsServerItem("co.ac", "whois.ripe.net"),
            new WhoIsServerItem("gv.ac", "whois.ripe.net"),
            new WhoIsServerItem("or.ac", "whois.ripe.net"),
            new WhoIsServerItem("af", "whois.netnames.net"),
            new WhoIsServerItem("am", "whois.nic.am"),
            new WhoIsServerItem("as", "whois.nic.as"),
            new WhoIsServerItem("at", "whois.nic.at"),
            new WhoIsServerItem("ac.at", "whois.nic.at"),
            new WhoIsServerItem("co.at", "whois.nic.at"),
            new WhoIsServerItem("gv.at", "whois.nic.at"),
            new WhoIsServerItem("or.at", "whois.nic.at"),
            new WhoIsServerItem("asn.au", "whois.aunic.net"),
            new WhoIsServerItem("com.au", "whois.aunic.net"),
            new WhoIsServerItem("edu.au", "whois.aunic.net"),
            new WhoIsServerItem("org.au", "whois.aunic.net"),
            new WhoIsServerItem("net.au", "whois.aunic.net"),
            new WhoIsServerItem("be", "whois.ripe.net"),
            new WhoIsServerItem("ac.be", "whois.ripe.net"),
            new WhoIsServerItem("br", "whois.nic.br"),
            new WhoIsServerItem("adm.br", "whois.nic.br"),
            new WhoIsServerItem("adv.br", "whois.nic.br"),
            new WhoIsServerItem("am.br", "whois.nic.br"),
            new WhoIsServerItem("arq.br", "whois.nic.br"),
            new WhoIsServerItem("art.br", "whois.nic.br"),
            new WhoIsServerItem("bio.br", "whois.nic.br"),
            new WhoIsServerItem("cng.br", "whois.nic.br"),
            new WhoIsServerItem("cnt.br", "whois.nic.br"),
            new WhoIsServerItem("com.br", "whois.nic.br"),
            new WhoIsServerItem("ecn.br", "whois.nic.br"),
            new WhoIsServerItem("eng.br", "whois.nic.br"),
            new WhoIsServerItem("esp.br", "whois.nic.br"),
            new WhoIsServerItem("etc.br", "whois.nic.br"),
            new WhoIsServerItem("eti.br", "whois.nic.br"),
            new WhoIsServerItem("fm.br", "whois.nic.br"),
            new WhoIsServerItem("fot.br", "whois.nic.br"),
            new WhoIsServerItem("fst.br", "whois.nic.br"),
            new WhoIsServerItem("g12.br", "whois.nic.br"),
            new WhoIsServerItem("gov.br", "whois.nic.br"),
            new WhoIsServerItem("ind.br", "whois.nic.br"),
            new WhoIsServerItem("inf.br", "whois.nic.br"),
            new WhoIsServerItem("jor.br", "whois.nic.br"),
            new WhoIsServerItem("lel.br", "whois.nic.br"),
            new WhoIsServerItem("med.br", "whois.nic.br"),
            new WhoIsServerItem("mil.br", "whois.nic.br"),
            new WhoIsServerItem("net.br", "whois.nic.br"),
            new WhoIsServerItem("nom.br", "whois.nic.br"),
            new WhoIsServerItem("ntr.br", "whois.nic.br"),
            new WhoIsServerItem("odo.br", "whois.nic.br"),
            new WhoIsServerItem("org.br", "whois.nic.br"),
            new WhoIsServerItem("ppg.br", "whois.nic.br"),
            new WhoIsServerItem("pro.br", "whois.nic.br"),
            new WhoIsServerItem("psc.br", "whois.nic.br"),
            new WhoIsServerItem("psi.br", "whois.nic.br"),
            new WhoIsServerItem("rec.br", "whois.nic.br"),
            new WhoIsServerItem("slg.br", "whois.nic.br"),
            new WhoIsServerItem("tmp.br", "whois.nic.br"),
            new WhoIsServerItem("tur.br", "whois.nic.br"),
            new WhoIsServerItem("tv.br", "whois.nic.br"),
            new WhoIsServerItem("vet.br", "whois.nic.br"),
            new WhoIsServerItem("zlg.br", "whois.nic.br"),
            new WhoIsServerItem("ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("ab.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("bc.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("mb.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("nb.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("nf.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("ns.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("nt.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("on.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("pe.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("qc.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("sk.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("yk.ca", "whois.cdnnet.ca"),
            new WhoIsServerItem("cc", "whois.nic.cc"),
            new WhoIsServerItem("cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("ac.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("com.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("edu.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("gov.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("net.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("org.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("bj.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("sh.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("tj.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("cq.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("he.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("nm.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("ln.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("jl.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("hl.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("js.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("zj.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("ah.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("hb.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("hn.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("gd.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("gx.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("hi.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("sc.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("gz.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("yn.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("xz.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("sn.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("gs.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("qh.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("nx.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("xj.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("tw.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("hk.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("mo.cn", "whois.cnnic.net.cn"),
            new WhoIsServerItem("cx", "whois.cx.net"),
            new WhoIsServerItem("cz", "whois.ripe.net"),
            new WhoIsServerItem("de", "whois.nic.de"),
            new WhoIsServerItem("dk", "whois.ripe.net"),
            new WhoIsServerItem("fo", "whois.ripe.net"),
            new WhoIsServerItem("com.ec", "whois.lac.net"),
            new WhoIsServerItem("org.ec", "whois.lac.net"),
            new WhoIsServerItem("net.ec", "whois.lac.net"),
            new WhoIsServerItem("mil.ec", "whois.lac.net"),
            new WhoIsServerItem("fin.ec", "whois.lac.net"),
            new WhoIsServerItem("med.ec", "whois.lac.net"),
            new WhoIsServerItem("gov.ec", "whois.lac.net"),
            new WhoIsServerItem("fr", "whois.nic.fr"),
            new WhoIsServerItem("tm.fr", "whois.nic.fr"),
            new WhoIsServerItem("com.fr", "whois.nic.fr"),
            new WhoIsServerItem("asso.fr", "whois.nic.fr"),
            new WhoIsServerItem("presse.fr", "whois.nic.fr"),
            new WhoIsServerItem("gf", "whois.nplus.gf"),
            new WhoIsServerItem("gs", "whois.adamsnames.tc"),
            new WhoIsServerItem("co.il", "whois.ripe.net"),
            new WhoIsServerItem("org.il", "whois.ripe.net"),
            new WhoIsServerItem("net.il", "whois.ripe.net"),
            new WhoIsServerItem("ac.il", "whois.ripe.net"),
            new WhoIsServerItem("k12.il", "whois.ripe.net"),
            new WhoIsServerItem("gov.il", "whois.ripe.net"),
            new WhoIsServerItem("muni.il", "whois.ripe.net"),
            new WhoIsServerItem("ac.in", "whois.iisc.ernet.in"),
            new WhoIsServerItem("co.in", "whois.iisc.ernet.in"),
            new WhoIsServerItem("ernet.in", "whois.iisc.ernet.in"),
            new WhoIsServerItem("gov.in", "whois.iisc.ernet.in"),
            new WhoIsServerItem("net.in", "whois.iisc.ernet.in"),
            new WhoIsServerItem("res.in", "whois.iisc.ernet.in"),
            new WhoIsServerItem("is", "whois.ripe.net"),
            new WhoIsServerItem("it", "whois.ripe.net"),
            new WhoIsServerItem("ac.jp", "whois.nic.ad.jp"),
            new WhoIsServerItem("co.jp", "whois.nic.ad.jp"),
            new WhoIsServerItem("go.jp", "whois.nic.ad.jp"),
            new WhoIsServerItem("or.jp", "whois.nic.ad.jp"),
            new WhoIsServerItem("ne.jp", "whois.nic.ad.jp"),
            new WhoIsServerItem("ac.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("co.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("go.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("ne.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("nm.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("or.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("re.kr", "whois.nic.or.kr"),
            new WhoIsServerItem("li", "whois.nic.li"),
            new WhoIsServerItem("lt", "whois.ripe.net"),
            new WhoIsServerItem("lu", "whois.ripe.net"),
            new WhoIsServerItem("asso.mc", "whois.ripe.net"),
            new WhoIsServerItem("tm.mc", "whois.ripe.net"),
            new WhoIsServerItem("com.mm", "whois.nic.mm"),
            new WhoIsServerItem("org.mm", "whois.nic.mm"),
            new WhoIsServerItem("net.mm", "whois.nic.mm"),
            new WhoIsServerItem("edu.mm", "whois.nic.mm"),
            new WhoIsServerItem("gov.mm", "whois.nic.mm"),
            new WhoIsServerItem("ms", "whois.adamsnames.tc"),
            new WhoIsServerItem("mx", "whois.nic.mx"),
            new WhoIsServerItem("com.mx", "whois.nic.mx"),
            new WhoIsServerItem("org.mx", "whois.nic.mx"),
            new WhoIsServerItem("net.mx", "whois.nic.mx"),
            new WhoIsServerItem("edu.mx", "whois.nic.mx"),
            new WhoIsServerItem("gov.mx", "whois.nic.mx"),
            new WhoIsServerItem("nl", "whois.domain-registry.nl"),
            new WhoIsServerItem("no", "whois.norid.no"),
            new WhoIsServerItem("nu", "whois.nic.nu"),
            new WhoIsServerItem("pl", "whois.ripe.net"),
            new WhoIsServerItem("com.pl", "whois.ripe.net"),
            new WhoIsServerItem("net.pl", "whois.ripe.net"),
            new WhoIsServerItem("org.pl", "whois.ripe.net"),
            new WhoIsServerItem("pt", "whois.ripe.net"),
            new WhoIsServerItem("com.ro", "whois.ripe.net"),
            new WhoIsServerItem("org.ro", "whois.ripe.net"),
            new WhoIsServerItem("store.ro", "whois.ripe.net"),
            new WhoIsServerItem("tm.ro", "whois.ripe.net"),
            new WhoIsServerItem("firm.ro", "whois.ripe.net"),
            new WhoIsServerItem("www.ro", "whois.ripe.net"),
            new WhoIsServerItem("arts.ro", "whois.ripe.net"),
            new WhoIsServerItem("rec.ro", "whois.ripe.net"),
            new WhoIsServerItem("info.ro", "whois.ripe.net"),
            new WhoIsServerItem("nom.ro", "whois.ripe.net"),
            new WhoIsServerItem("nt.ro", "whois.ripe.net"),
            new WhoIsServerItem("ru", "whois.ripn.net"),
            new WhoIsServerItem("com.ru", "whois.ripn.net"),
            new WhoIsServerItem("net.ru", "whois.ripn.net"),
            new WhoIsServerItem("org.ru", "whois.ripn.net"),
            new WhoIsServerItem("se", "whois.nic-se.se"),
            new WhoIsServerItem("si", "whois.arnes.si"),
            new WhoIsServerItem("com.sg", "whois.nic.net.sg"),
            new WhoIsServerItem("org.sg", "whois.nic.net.sg"),
            new WhoIsServerItem("net.sg", "whois.nic.net.sg"),
            new WhoIsServerItem("gov.sg", "whois.nic.net.sg"),
            new WhoIsServerItem("sk", "whois.ripe.net"),
            new WhoIsServerItem("st", "whois.nic.st"),
            new WhoIsServerItem("tc", "whois.adamsnames.tc"),
            new WhoIsServerItem("tf", "whois.adamsnames.tc"),
            new WhoIsServerItem("ac.th", "whois.thnic.net"),
            new WhoIsServerItem("co.th", "whois.thnic.net"),
            new WhoIsServerItem("go.th", "whois.thnic.net"),
            new WhoIsServerItem("mi.th", "whois.thnic.net"),
            new WhoIsServerItem("net.th", "whois.thnic.net"),
            new WhoIsServerItem("or.th", "whois.thnic.net"),
            new WhoIsServerItem("tj", "whois.nic.tj"),
            new WhoIsServerItem("tm", "whois.nic.tm"),
            new WhoIsServerItem("to", "monarch.tonic.to"),
            new WhoIsServerItem("bbs.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("com.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("edu.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("gov.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("k12.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("mil.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("net.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("org.tr", "whois.metu.edu.tr"),
            new WhoIsServerItem("com.tw", "whois.twnic.net"),
            new WhoIsServerItem("net.tw", "whois.twnic.net"),
            new WhoIsServerItem("org.tw", "whois.twnic.net"),
            new WhoIsServerItem("ac.uk", "whois.ja.net"),
            new WhoIsServerItem("uk.co", "whois.uk.co"),
            new WhoIsServerItem("uk.com", "whois.nomination.net"),
            new WhoIsServerItem("uk.net", "whois.nomination.net"),
            new WhoIsServerItem("gb.com", "whois.nomination.net"),
            new WhoIsServerItem("gb.net", "whois.nomination.net"),
            new WhoIsServerItem("vg", "whois.adamsnames.tc"),
            new WhoIsServerItem("ac.za", "whois.co.za"),
            new WhoIsServerItem("alt.za", "whois.co.za"),
            new WhoIsServerItem("co.za", "whois.co.za"),
            new WhoIsServerItem("edu.za", "whois.co.za"),
            new WhoIsServerItem("gov.za", "whois.co.za"),
            new WhoIsServerItem("mil.za", "whois.co.za"),
            new WhoIsServerItem("net.za", "whois.co.za"),
            new WhoIsServerItem("ngo.za", "whois.co.za"),
            new WhoIsServerItem("nom.za", "whois.co.za"),
            new WhoIsServerItem("org.za", "whois.co.za"),
            new WhoIsServerItem("school.za", "whois.co.za"),
            new WhoIsServerItem("tm.za", "whois.co.za"),
            new WhoIsServerItem("web.za", "whois.co.za"),
            new WhoIsServerItem("sh", "whois.nic.sh"),
            new WhoIsServerItem("kz", "whois.domain.kz"),
            new WhoIsServerItem("asia", "whois.nic.asia"),
            new WhoIsServerItem("fm", "whois.nic.fm")
        };
 
        /// <summary>
        /// WhoIs 信息服务器表示“没有找到”的字符串
        /// </summary>
        public static readonly WhoIsServerNotFoundItem[] Whois_NotFoundString =
        {
            new WhoIsServerNotFoundItem("whois.internic.net", "No match"),
            new WhoIsServerNotFoundItem("whois.neulevel.biz", "Not found"),
            new WhoIsServerNotFoundItem("whois.nic.la", "DOMAIN NOT FOUND"),//需要修改
            new WhoIsServerNotFoundItem("whois.afilias.info", "NOT FOUND"),
            new WhoIsServerNotFoundItem("whois.belizenic.bz", "No match for"),
            new WhoIsServerNotFoundItem("whois.website.ws", "No match for"),
            new WhoIsServerNotFoundItem("whois.nic.uk", "No match"),
            new WhoIsServerNotFoundItem("whois.bulkregister.com", "Not found"),
            new WhoIsServerNotFoundItem("whois.centralnic.com", "No match"),
            new WhoIsServerNotFoundItem("whois.ripe.net", "No entries found"),
            new WhoIsServerNotFoundItem("whois.netnames.net", "No Match"),
            new WhoIsServerNotFoundItem("whois.nic.am", "No information available"),
            new WhoIsServerNotFoundItem("whois.nic.as", "Domain Not Found"),
            new WhoIsServerNotFoundItem("whois.nic.at", "No entries found"),
            new WhoIsServerNotFoundItem("whois.aunic.net", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nic.br", "No match for"),
            new WhoIsServerNotFoundItem("whois.cdnnet.ca", "Not found"),
            new WhoIsServerNotFoundItem("whois.nic.cc", "No match"),
            new WhoIsServerNotFoundItem("whois.cnnic.net.cn", "No entries"),
            new WhoIsServerNotFoundItem("snail.cnnic.net.cn", "No entries"),
            new WhoIsServerNotFoundItem("whois.cx.net", "No match for"),
            new WhoIsServerNotFoundItem("whois.co.za", "No information available"),
            new WhoIsServerNotFoundItem("whois.twnic.net", "No Records Found"),
            new WhoIsServerNotFoundItem("whois.metu.edu.tr", "Not found in database"),
            new WhoIsServerNotFoundItem("whois.adamsnames.tc", "is not registered"),
            new WhoIsServerNotFoundItem("whois.ja.net", "Sorry - no"),
            new WhoIsServerNotFoundItem("whois.nomination.net", "No match for"),
            new WhoIsServerNotFoundItem("whoic.thnic.net", "No entries"),
            new WhoIsServerNotFoundItem("monarch.tonic.to", "Not found"),
            new WhoIsServerNotFoundItem("whois.nic.tm", "No match"),
            new WhoIsServerNotFoundItem("whois.nic.tj", "No match"),
            new WhoIsServerNotFoundItem("whois.nic.st", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nic.net.sg", "NO entry found"),
            new WhoIsServerNotFoundItem("whois.arnes.si", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nic-se.se", "No data found"),
            new WhoIsServerNotFoundItem("whois.ripn.net", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nic.nu", "Match for"),
            new WhoIsServerNotFoundItem("whois.norid.no", "no matches"),
            new WhoIsServerNotFoundItem("whois.domain-registry.nl", "not a registered domain"),
            new WhoIsServerNotFoundItem("whois.nic.mx", "Referencias de Organization No Encontradas"),
            new WhoIsServerNotFoundItem("whois.nic.mm", "No domains matched"),
            new WhoIsServerNotFoundItem("whois.net.au", "AUNIC -T domain"),
            new WhoIsServerNotFoundItem("whois.nic.bt", "shrubbery.com"),
            new WhoIsServerNotFoundItem("whois.cdnnet.ca", "Not found"),
            new WhoIsServerNotFoundItem("whois.nic.ch", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nic.cx", "No match for"),
            new WhoIsServerNotFoundItem("whois.nic.de", "No entries found"),
            new WhoIsServerNotFoundItem("whois.lac.net", "No match found"),
            new WhoIsServerNotFoundItem("whois.nic.fr", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nplus.gf", "not found in our database"),
            new WhoIsServerNotFoundItem("whois.iisc.ernet.in", "no entries found"),
            new WhoIsServerNotFoundItem("whois.nic.ad.jp", "No match"),
            new WhoIsServerNotFoundItem("whois.nic.or.kr", "is not registered"),
            new WhoIsServerNotFoundItem("whois.nic.li", "No entries found"),
            new WhoIsServerNotFoundItem("whois.nic.mm", "No domains matched"),
            new WhoIsServerNotFoundItem("whois.norid.no", "no matches"),
            new WhoIsServerNotFoundItem("whois.nic-se.se", "No data found"),
            new WhoIsServerNotFoundItem("monarch.tonic.tj", "Not found"),
            new WhoIsServerNotFoundItem("whois.uk.co", "NO MATCH"),
            new WhoIsServerNotFoundItem("whois.nic.sh", "No match"),
            new WhoIsServerNotFoundItem("whois.domain.kz", "No entries found"),
            new WhoIsServerNotFoundItem("whois.crsnic.net", "No match for"),
            new WhoIsServerNotFoundItem("whois.nic.asia", "NOT FOUND"),
             new WhoIsServerNotFoundItem("whois.nic.fm", "NOT FOUND")
        };
        #endregion
 
        public WhoIsQuery() { }
 
        /// <summary>
        /// 查询域名的 WhoIs 信息
        /// </summary>
        /// <param name="domain">要查询的域名</param>
        /// <param name="type">指定查询类型 WhoIsQueryType</param>
        /// <returns>
        /// 执行成功: 返回详细的WhoIs信息
        /// 执行失败:返回相就的异常或是错误信息
        /// </returns>
        public static string WhoIs(string domain)
        {
            return WhoIs(domain, getWhoIsServer(domain));
        }
 
 
        /// <summary>
        /// 查询域名的 WhoIs 信息
        /// </summary>
        /// <param name="domain">要查询的域名</param>
        /// <param name="server">WhoIs 服务器地址</param>
        /// <param name="port">WhoIs 查询类型</param>
        /// <returns>
        /// 执行成功: 返回详细的WhoIs信息
        /// 执行失败:返回相就的异常或是错误信息
        /// </returns>
        public static string WhoIs(string domain, string server)
        {
            //return string
            string returnstr = "String Error";
            returnstr = TcpWhoIs(domain, server, 43);
            string returnold = "";
            try
            {
                //判断是否查询出域名WhoIs基本信息
                if (returnstr.Contains(getWhoIsServerNotFoundString(server)))
                {
                    returnstr = "String Error";
                }
                else
                {
                    if (returnstr.Contains("Whois Server:"))
                    {
                        //保存现在基本WhoIs信息
                        returnold = returnstr;
                        returnstr = returnstr.Substring(returnstr.IndexOf("Whois Server:"));
                        returnstr = returnstr.Substring(0, returnstr.IndexOf("<br/>\r\n")).Replace("Whois Server:", "");
                        returnstr = TcpWhoIs(domain, returnstr.Trim(), 43);
                    }
                }
            }
            catch (Exception)
            {
                returnstr = "您输入的域名有错!!!";
            }
 
            returnstr = returnold + returnstr;
 
            return returnstr;
        }
 
        /// <summary>
        /// 查询域名的 WhoIs 信息 终端查询方式
        /// </summary>
        /// <param name="domain">要查询的域名</param>
        /// <param name="server">WhoIs 服务器地址</param>
        /// <param name="port">WhoIs 服务器端口</param>
        /// <returns>
        /// 执行成功: 返回详细的WhoIs信息
        /// 执行失败:返回相就的异常或是错误信息
        /// </returns>
        public static string TcpWhoIs(string domain, string server, int port = 43)
        {
            // 连接域名 Whois 查询服务器
            TcpClient tcp = new TcpClient();
            //return string
            string returnstr = "String Error";
            try
            {
                tcp.Connect(server, port);
            }
            catch (SocketException)
            {
                returnstr = "连接 Whois 服务器失败 ,请检查您输入的域名是否正确!! ";
            }
 
            // 向域名 Whois 查询服务器发送查询的域名
            try
            {
                //构造发送的字符串
                domain += "\r\n";
                Byte[] DomainBytes = System.Text.Encoding.ASCII.GetBytes(domain.ToCharArray());
                // 将域名发送到域名 Whois 查询服务器
                Stream WhoisStream = tcp.GetStream();
                WhoisStream.Write(DomainBytes, 0, domain.Length);
                //返回流
                StreamReader WhoisStreamReader = new StreamReader(WhoisStream, System.Text.Encoding.UTF8);
                StringBuilder WhoisInfo = new StringBuilder();
                string WhoisLine = null;
 
                while (null != (WhoisLine = WhoisStreamReader.ReadLine()))
                {
                    WhoisInfo.Append(WhoisLine + "<br/>\r\n");
                }
 
                returnstr = WhoisInfo.ToString();
            }
            catch (Exception)
            {
                returnstr = "网络无响应,或者是您的域名输入有误";
            }
            finally
            {
                tcp.Close();
            }
            return returnstr;
        }
 
        /// <summary>
        /// 根据域名获取域名的 WhoIs 服务器地址
        /// </summary>
        /// <param name="domain">要查询的域名</param>
        /// <returns>
        /// 执行成功: 返回传入域名对就的终级WhoIs服务器
        /// 执行失败:返回"String Error"
        /// </returns>
        private static string getWhoIsServer(string domain)
        {
            string[] arr = domain.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
            string tld = arr[arr.Length - 1];
 
            var query = (from x in WhoIs_InfoServers
                         where x.Tld == tld
                         select x).FirstOrDefault();
            return query == null ? "String Error" : query.Server;
        }
 
        /// <summary>
        /// 获取 WhoIs 服务器“域名不存在”信息的表示字符串
        /// </summary>
        /// <param name="server">WhoIs 服务器名称</param>
        /// <returns>
        /// 执行成功: 根据传入的服务器返回可能出现的异常字符串
        /// 执行失败:返回"No match"
        /// </returns>
        private static string getWhoIsServerNotFoundString(string server)
        {
            var query = (from x in Whois_NotFoundString
                         where x.Server == server
                         select x).FirstOrDefault();
            return query == null ? "No match" : query.NotFoundString;
        }
 
        #region 属性
 
        #endregion
    }
 
    /// <summary>
    /// WhoIs查询类型
    /// </summary>
    public enum WhoIsQueryType
    {
        /// <summary>
        /// 终端服务器查询方式默认
        /// </summary>
        BaseType = 0,
 
        /// <summary>
        /// 万网查询方式
        /// </summary>
        NetType = 1,
 
        /// <summary>
        /// 新网查询方式
        /// </summary>
        XinnetTyep = 2
    }
 
    /// <summary>
    /// 表示一个顶级域的 WhoIs 服务器地址
    /// </summary>
    public class WhoIsServerItem
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="tld">顶级域</param>
        /// <param name="server">WhoIs 服务器地址</param>
        public WhoIsServerItem(string tld, string server)
        {
            this.Tld = tld;
            this.Server = server;
        }
 
        /// <summary>
        /// 顶级域
        /// </summary>
        public string Tld { get; set; }
 
        /// <summary>
        /// WhoIs 服务器地址
        /// </summary>
        public string Server { get; set; }
    }
 
    /// <summary>
    /// 表示一个顶级域的 WhoIs 服务器“没有找到”字符串的数据
    /// </summary>
    public class WhoIsServerNotFoundItem
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="server">WhoIs 服务器地址</param>
        /// <param name="notFoundString">表示“没有找到”的字符串</param>
        public WhoIsServerNotFoundItem(string server, string notFoundString)
        {
            this.Server = server;
            this.NotFoundString = notFoundString;
        }
 
        /// <summary>
        /// WhoIs 服务器地址
        /// </summary>
        public string Server { get; set; }
 
        /// <summary>
        /// 表示“没有找到”的字符串
        /// </summary>
        public string NotFoundString { get; set; }
    }
}



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2012-11-9 18:54:23 | 显示全部楼层
谢谢老大分享。
发表于 2012-11-14 16:55:07 | 显示全部楼层
很详细,支持
 楼主| 发表于 2012-11-14 17:32:28 | 显示全部楼层
smlianqi 发表于 2012-11-14 16:55
很详细,支持

这个是以前的写法,估计有点老了,但功能还是可以实现的,仅做参考吧。
发表于 2013-10-28 09:10:05 | 显示全部楼层
为什么我查出来的cnblogs.com的信息之显示到你贴出代码的地54行呢,下边就都没了

54.The Registry database contains ONLY .COM, .NET, .EDU domains and
发表于 2013-10-28 09:10:26 | 显示全部楼层
站长苏飞 发表于 2012-11-14 17:32
这个是以前的写法,估计有点老了,但功能还是可以实现的,仅做参考吧。

为什么我查出来的cnblogs.com的信息之显示到你贴出代码的地54行呢,下边就都没了

54.The Registry database contains ONLY .COM, .NET, .EDU domains and
 楼主| 发表于 2013-10-28 09:17:43 | 显示全部楼层
hu_service 发表于 2013-10-28 09:10
为什么我查出来的cnblogs.com的信息之显示到你贴出代码的地54行呢,下边就都没了

54.The Registry dat ...

有的能查出来有的查不出来,有的是不允许查询的,这可能是用户禁止了,正常
发表于 2013-10-28 11:35:35 | 显示全部楼层
站长苏飞 发表于 2013-10-28 09:17
有的能查出来有的查不出来,有的是不允许查询的,这可能是用户禁止了,正常

那为何站长工具可以查得到呢,
 楼主| 发表于 2013-10-28 14:46:42 | 显示全部楼层
hu_service 发表于 2013-10-28 11:35
那为何站长工具可以查得到呢,

他们是收集的,也不是查询的,也许是在能查询的时候查到了,保存进来的。这都不好说。或者是说在那个Whois服务器上可以找,这都不好说,站长工具不是时时的,而且他们渠道比较多,这能比吗?
发表于 2013-10-29 15:38:48 | 显示全部楼层
站长苏飞 发表于 2013-10-28 14:46
他们是收集的,也不是查询的,也许是在能查询的时候查到了,保存进来的。这都不好说。或者是说在那个Whoi ...

问个问题再,google的搜索结果为何无法抓取到呢,赋值URL直接到浏览器是有内容的,抓取抓不到


HttpHelper _http = new HttpHelper();
            HttpItem _item = new HttpItem()
            {
                URL = "http://www.google.com.hk/#newwindow=1&q=钢铁&safe=strict&start=10",
                Method = "get"
            };
            HttpResult _result = _http.GetHtml(_item);
            string _html = _result.Html;
            string _cookie = _result.Cookie;

            if (_result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return _html;
            }

您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-4-19 10:33

© 2014-2021

快速回复 返回顶部 返回列表