Bookmark Topic Watch Topic
 
friki data migration
Ranch Hand
Posts: 772
1
  • Mark post as helpful
  • send pies
  • Report post to moderator
There are numerous sample codes floating around the web that show how to do a Whois lookup, but none seem to get it quite right. So here's code that works for all TLDs, and also smoothes out some of the peculiarities of various Whois servers. It uses the Apache Commons Net library (which by itself does not implement a comprehensive lookup solution).

The general approach is:

  • Perform a Whois lookup against the IANA server at whois.iana.org; the result will point to the authoritative Whois server for the domain in question.
  • Extract the server name from the response, and then perform a lookup against that server.
  • This response may point to a more specific Whois server that has additional information, often run by the host's registrar. If it does, an additional lookup is performed against that server.


  • Additional difficulties to watch out for:

  • The Whois server for the ".jp" TLD returns Japanese characters, which is generally not wanted; so an option is used to turn that off.
  • The server handling the ".de" TLD needs an additional flag passed in, or nothing will be returned. Also, after a few lookups, this server stops returning results to a particular IP address for a while; so be careful how many requests for ".de" domains you send.
  • The results for various domains (like google.com, apple.com. yahoo.com, microsoft.com etc.) contain bogus subdomains that prevent proper results for the actual domain from being returned; so a special syntax is used to filter out those junk entries for the ".com" TLD.
  • An additional option is passed on for ".dk" domains so that more information is shown for them.





  • CodeBarn CategoryCodeSamples
     
    Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
    the new thread boost feature: great for the advertiser and smooth for the coderanch user
    https://coderanch.com/t/674455/Thread-Boost-feature
      Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!