-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
f3cd7d1
commit 34e7a4e
Showing
5 changed files
with
64 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
var fs = require('fs'), https = require('https'); | ||
|
||
var dom = ['google.com', 'youtube.com', 'facebook.com', 'whoisxmlapi.com']; | ||
var srv = 'www.whoisxmlapi.com', url = '/BulkWhoisLookup/bulkServices/'; | ||
var username = 'Your bulk whois api username'; | ||
var pass = 'Your bulk whois api password'; | ||
var file = 'bulk.csv'; | ||
|
||
function api(path, data, callback) | ||
{ | ||
var baseData = { | ||
password: pass, | ||
username: username, | ||
outputFormat: 'json' | ||
}; | ||
|
||
var body = ''; | ||
var opts = { | ||
host: srv, | ||
path: url + path, | ||
method:'POST', | ||
headers: {'Content-Type': 'application/json'} | ||
}; | ||
|
||
https.request(opts, function(response) { | ||
response.on('data', function(chunk) { | ||
body += chunk; | ||
}); | ||
response.on('end', function() { | ||
callback(body); | ||
}); | ||
}).end(JSON.stringify(Object.assign({}, baseData, data))); | ||
} | ||
|
||
// This will save whois record info for all domains as 'bulk.csv' in current | ||
// directory. | ||
|
||
api('bulkWhois', {domains:dom}, function(body) { | ||
var id = { | ||
requestId: JSON.parse(body).requestId, | ||
startIndex: dom.length + 1 | ||
}; | ||
var timer = setInterval(function() { | ||
api('getRecords', Object.assign({},id,{maxRecords:0}),function(body) { | ||
if (JSON.parse(body).recordsLeft) { | ||
return; | ||
} | ||
clearInterval(timer); | ||
if (typeof JSON.parse(body).recordsLeft === 'undefined') { | ||
return; | ||
} | ||
api('download', id, function(csv) { | ||
fs.writeFile(file,csv); | ||
}); | ||
}); | ||
}, 3000); | ||
}); |
File renamed without changes.
File renamed without changes.