Search code examples
rubywhoiswhois-ruby

Ruby WHOIS gem registry doesn't capture Registrar info. Any alternatives?


This code returns a payload of limited value

2.4.0 :001 > require 'whois'; require 'whois-parser'
 => true
2.4.0 :002 > client = Whois::Client.new(timeout: 10)
 => #<Whois::Client:0x007f87f1075910 @timeout=10, @settings={}>
2.4.0 :003 > results = client.lookup("stackoverflow.com")
 => "   Domain Name: STACKOVERFLOW.COM\r\n # ...

Three details I've truncated from that string are:

  1. The WHOIS registrar of record for this domain is whois.name.com .
  2. The registry is Verisign.
  3. Verisign does not return as much detail as name.com.

This seems to be equal to the difference between

whois -h whois.verisign-grs.com stackoverflow.com

versus

whois -h whois.name.com stackoverflow.com

This can be repeated for many domains, for example facebook.com or daringfireball.net. Given the registrar contains more information than the registry, what is best way of obtaining that additional information?

Obviously, I can ingest the raw string from the registrar and parse as best as I can. But, have the whois gem and all other Ruby solutions never addressed the need to get the full available record from Registrars? And if not, how can I use the built-in parsing of the whois gem to inspect a record from Registrars?


Solution

  • .COM is a thin whois system. That is, you first contact Verisign, the whois response you obtain contains the host of the next whois server you have to query.

    As a result, the final whois response is a combination of the response from 2 servers.

    In order to extract ALL the details, you need a parser for each server you obtain a response from. Specifically, Verisign and Name.com in your case.

    The library has a Verisign parser, but has no Name.com parser. Therefore, it's not able to pull the details from the response coming from Name.com https://github.com/weppos/whois-parser/tree/master/lib/whois/parsers

    You can define a specific parser for Name.com, and the library will attempt to fetch the details from it. Examples are Enom.com and GoDaddy.com parsers: https://github.com/weppos/whois-parser/blob/master/lib/whois/parsers/whois.enom.com.rb