Asp.net Domain Whois功能的實現

來源:互聯網
上載者:User

前段時間花了幾個晚上做了個線上工具網站。最近沒空加新工具,如果大家有需要什麼線上工具的可以提出來,

我比較傾向於做開發人員相關的工具,像那類線上查姓名看吉凶的工具就沒什麼興趣了。

Domain Whois的資料主要是來源於某個提供Domain Whois查詢的網站,因為這個網站查詢出來的資料比其他網站服務詳細,有包括網域名稱擁有者的地址電話等資訊。

但是他不允許同一個IP查詢太多次,這一點我一直沒想到辦法解決。

主要代碼:

        public ActionResult DomainWhois(string domain)        {            if (!string.IsNullOrWhiteSpace(domain))            {                try                {                    var client = new WebClient();                    client.Encoding = System.Text.UTF8Encoding.UTF8;                    var html = client.DownloadString(new Uri("http://whois.elmundo.es/whois/cgi/whois.html?q=" + domain));                    var parser = new Parser(new Lexer(html));                    var nodes = parser.ExtractAllNodesThatMatch(new TagNameFilter("td"));                    for (var i = 0; i < nodes.Count; i++)                    {                        var tag = nodes[i] as ITag;                        if (tag != null && tag.GetAttribute("bgcolor") == "#d0d0d0")                        {                            ViewBag.Result = tag.ToHtml();                            break;                        }                    }                }                catch                {                    ViewBag.Result = Resources.NoResult;                }            }            return View();        }

  

上面代碼用到了Winista.HTMLParser組件來解析接收到的html代碼。我想有了Winista.HTMLParser想偷哪個網站的資料都很方便。

運行結果:

Demo: http://tools.susucms.com/Query/DomainWhois?domain=susucms.com

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.