我想要能够通过客户端
javascript获取whois数据(和idn域).可能吗?也许有一些免费的REST类似的WhoIs服务存在?
解决方法
尝试使用
http://whoisxmlapi.com服务.
服务网址:http://www.whoisxmlapi.com/whoisserver/WhoisService
你需要指定outputFormat = json和domainName = insert_domain_here参数..
示例URL:http://www.whoisxmlapi.com/whoisserver/WhoisService?outputFormat=json&domainName=stackoverflow.com.
示例代码(使用jQuery来简化AJAX通信):
- $.ajax({
- url: 'http://www.whoisxmlapi.com/whoisserver/WhoisService',dataType: 'jsonp',data: {
- domainName: 'stackoverflow.com',outputFormat: 'json'
- },success: function(data) {
- console.log(data.WhoisRecord);
- }
- });
更新:
上面提到的服务不是免费的,但是有几个免费的whois服务提供HTML输出,通过使用YQL可以检索HTML作为JS.有关详细信息,请参阅THIS答案.
示例(使用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');
- }
- });
您需要查看HTML文档的结构,并选择,处理和显示您感兴趣的数据.该示例只是打印整个表而不进行任何处理.