Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whois with JavaScript

I want to be able to get whois data (and idn domains too) by client-side javascript. Is it possible? Maybe some free REST-like WhoIs service exists?

like image 623
Dmitry Belaventsev Avatar asked Dec 08 '11 18:12

Dmitry Belaventsev


2 Answers

An npm package called node-whois did the job for me. It's server side JS, not client side, but perhaps this will help someone.

like image 102
demiters Avatar answered Sep 27 '22 20:09

demiters


Try using http://whoisxmlapi.com service.

The service URL: http://www.whoisxmlapi.com/whoisserver/WhoisService

You need to specify outputFormat=json and domainName=insert_domain_here parameters..

Example URL: http://www.whoisxmlapi.com/whoisserver/WhoisService?outputFormat=json&domainName=stackoverflow.com.

Example code (using jQuery to simplify AJAX communication):

$.ajax({
  url: 'http://www.whoisxmlapi.com/whoisserver/WhoisService',
  dataType: 'jsonp',
  data: {
    domainName: 'stackoverflow.com',
    outputFormat: 'json'
  },
  success: function(data) {
    console.log(data.WhoisRecord);
  }
});

HERE is the working code.

Update:

The service mentioned above is not free, but there are several free whois services that are providing HTML output and by using YQL you can retrieve the HTML as a JS. See THIS answer for more details.

Example (using jQuery & jquery.xdomainajax):

var domain = 'stackoverflow.com';
$.ajax({
  url: 'http://whois.webhosting.info/' + domain,
  type: 'GET',
  success: function(res) {
    // using jQuery to find table with class "body_text" and appending it to a page
    $(res.responseText).find('table.body_text').appendTo('body');
  }
});

HERE is the working code.

You need to have a look at the structure of the HTML document and select, process and display the data you are interested in. The example is just printing whole table without any processing.

like image 41
kubetz Avatar answered Sep 27 '22 21:09

kubetz