Parse whois answer

China☆狼群 提交于 2019-12-21 09:06:06

问题


I want to create whois class like that

public class DomainInfo
{

     public string NameServer {get;set;}        
     public string CreationDate {get;set;}
     public string UpdatedDate {get;set;} 
     public string ExpirationDate {get;set;}
     public string Status {get;set;}        
     public string RegistrantName {get;set;}
     public string RegistrantOrganization {get;set;}
     public string Registrantemail {get;set;}        
     public static DomainInfo Parse(string inputData)
  {
     ......
  }
}

But I have some problems because different DNS servers return different answers and it's a very difficult task to parse returned answers. How can this be done?


回答1:


Here is a link to a blog post with some C# code that might help:

http://blog.flipbit.co.uk/2009/06/querying-whois-server-data-with-c.html

You could probably tweak the parsing code as you run into instances where you are not getting the data you need but I don't think there is a one shoe fits all solution.




回答2:


It can't be done without implementing a parser for every whois database you come across.

Whois has no standardized format, most registries don't even have all that info available over whois but instead give you a handle that you can check over HTTP while filling out a captcha:

$ whois google.no
% Kopibeskyttet, se http://www.norid.no/domenenavnbaser/whois/kopirett.html
% Rights restricted by copyright. See http://www.norid.no/domenenavnbaser/whois/kopirett.en.html

Domain Information

Domain Name................: google.no
Organization Handle........: GNA78O-NORID
Registrar Handle...........: REG466-NORID
Legal-c Handle.............: RH1355P-NORID
Tech-c Handle..............: JM722P-NORID
Zone-c Handle..............: JM722P-NORID
...


来源:https://stackoverflow.com/questions/2413431/parse-whois-answer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!