查找域名
//方式1:
var dns = require('dns');
dns.lookup('www.qq.com', function(err, address, family){
if(err) throw err;
console.log('例子A: ' + address);
});
//方式2:
var dns = require('dns');
var options = {all: true};
dns.lookup('www.qq.com', options, function(err, address, family){
if(err) throw err;
console.log('例子B: ' + address);
});
//方式3:
var dns = require('dns');
dns.resolve4('id.qq.com', function(err, address){
if(err) throw err;
console.log( JSON.stringify(address) );
});
网友评论