Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse whois answer

Tags:

c#

whois

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?

like image 488
Neir0 Avatar asked Mar 09 '10 23:03

Neir0


2 Answers

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
...
like image 159
Martin Avatar answered Nov 05 '22 02:11

Martin


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.

like image 34
Kelsey Avatar answered Nov 05 '22 04:11

Kelsey