9

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?

bortzmeyer
  • 34,164
  • 12
  • 67
  • 91
Neir0
  • 12,849
  • 28
  • 83
  • 139
  • You mean "different whois servers"? Because DNS servers are not whois servers, it is a completely different protocol. – bortzmeyer Mar 10 '10 at 16:29
  • I know this is a late reply but I thought I'd throw in my two cents; you need to create a parser for every TLD and gTLD (all 1000+ of them), I wouldn't suggest this route unless you know you'll only ever need a handful of TLDs. Besides parsing the data, rate limiting and blocking policies also need to be considered and planned for, this is why I stopped trying to build my own solution and just started using a [hosted solution](https://jsonwhoisapi.com). – sousdev Sep 02 '16 at 22:04

2 Answers2

4

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
...
Martin
  • 37,119
  • 15
  • 73
  • 82
2

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.

Kelsey
  • 47,246
  • 16
  • 124
  • 162
  • Rolling your own parser will yield a great deal of errors and incorrect parsing however if you are adamant in creating your own I'd suggest create a parsing template for each TLD (all 1.5K+ of them). Or do as I do and use a free [hosted service](https://jsonwhoisapi.com) – sousdev Sep 18 '16 at 12:12