使用 JavaScript 的 Whois

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8435678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 03:26:56  来源:igfitidea点击:

Whois with JavaScript

javascriptwhois

提问by Dmitry Belaventsev

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?

我希望能够通过客户端 javascript 获取 whois 数据(以及 idn 域)。是否可以?也许存在一些免费的类似于 REST 的 WhoIs 服务?

采纳答案by kubetz

Try using http://whoisxmlapi.comservice.

尝试使用http://whoisxmlapi.com服务。

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

服务网址:http: //www.whoisxmlapi.com/whoisserver/WhoisService

You need to specify outputFormat=jsonand domainName=insert_domain_hereparameters..

您需要指定outputFormat=jsondomainName=insert_domain_here参数..

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

示例 URLhttp: //www.whoisxmlapi.com/whoisserver/WhoisService? outputFormat= json& domainName= stackoverflow.com

Example code(using jQuery to simplify AJAX communication):

示例代码(使用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);
  }
});

HEREis 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 THISanswer for more details.

上面提到的服务不是免费的,但是有几个免费的 whois 服务提供 HTML 输出,通过使用 YQL,您可以将 HTML 检索为 JS。有关更多详细信息,请参阅答案。

Example(using jQuery & jquery.xdomainajax):

示例(使用 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');
  }
});

HEREis 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.

您需要查看 HTML 文档的结构并选择、处理和显示您感兴趣的数据。示例只是打印整个表格,没有任何处理。

回答by Meisam Mulla

What you can do if you have exec() enabled in php is create a php file with the following:

如果您在 php 中启用了 exec(),您可以使用以下内容创建一个 php 文件:

exec('whois domain.com');

and then create aa .ajax() request to the php script where you pass the domain name and output it.

然后创建一个 .ajax() 请求到 php 脚本,在那里你传递域名并输出它。

回答by Arturs Demiters

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

一个名为node-whois的 npm 包为我完成了这项工作。它是服务器端 JS,而不是客户端,但也许这会对某人有所帮助。

回答by user793439

i'm also trying to find out a free whois provider with JSON output, couldn't find one. But, there are WHOIS windows client provided by Microsoftand like someone mentioned above, we can use PHP/cgi to get the details.

我也在尝试找到一个带有 JSON 输出的免费 whois 提供商,但找不到。但是,有微软提供的 WHOIS windows 客户端,就像上面提到的那样,我们可以使用 PHP/cgi 来获取详细信息。

I'm not sure whether there's any WHOIS lookup/query provider gives JSON output at free cost.

我不确定是否有任何 WHOIS 查找/查询提供程序免费提供 JSON 输出。

BTW, i just found this phpWhoisfrom sourceforge.net, would be a good starting point to use whois from the server. This is the library used by RoboWhois / RubyWhois provider as well.

顺便说一句,我刚刚从 sourceforge.net找到了这个phpWhois,这将是从服务器使用 whois 的一个很好的起点。这也是 RoboWhois / RubyWhois 提供商使用的库。