简体   繁体   English

使用 Node.js,如何查看域名是否已注册?

[英]Using Node.js, how can I check whether a domain name is registered?

I'm building a simple webapp to teach myself node.js, and in it I need to check whether a certain domain name specified by the user is registered.我正在构建一个简单的webapp来自学node.js,在其中我需要检查用户指定的某个域名是否已注册。 I'm not really sure how to go about this and I'd appreciate it if anybody could enlighten me.我不太确定如何解决这个问题,如果有人能启发我,我将不胜感激。

Take a look at this article by Matt Brubeck:看看 Matt Brubeck 的这篇文章:

http://limpet.net/mbrubeck/2010/01/13/si-unit-domains-node-js.html http://limpet.net/mbrubeck/2010/01/13/si-unit-domains-node-js.html

There is a Node.js script that does exactly that.有一个 Node.js 脚本可以做到这一点。

I think the best way to do this is to use the dns module to do a resolve , and if nothing is returned or an error is thrown it's not registered yet.我认为最好的方法是使用dns模块进行resolve ,如果没有返回任何内容或抛出错误,则说明尚未注册。

https://nodejs.org/api/dns.html https://nodejs.org/api/dns.html

Run something like this:运行如下:

//loads the Node core DNS module
var dns = require ( 'dns' )

function checkAvailable( url ) {
  //uses the core modules to run an IPv4 resolver that returns 'err' on error
  dns.resolve4( url, function (err, addresses) {
    if (err) console.log (url + " is possibly available : " + err)
  })
}
// calls the function of a given url        
checkAvailable( "ohwellhaithar.com" )

I did not found the correct answer for this question.我没有找到这个问题的正确答案。 My solution is over here我的解决方案在这里

https://www.npmjs.com/package/whois

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM