-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
49 lines (40 loc) · 903 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import fs from 'fs';
import { API_KEY, domainList } from './config.js';
const output = {};
async function getWhoisData(domainName) {
try {
const res = await fetch(`https://api.ip2whois.com/v2?key=${API_KEY}&domain=${domainName}&format=json`);
//console.log('res', res);
if(res.ok) {
const json = await res.json();
//console.log('json', json);
output[domainName] = {
domainName,
...json,
};
} else {
output[domainName] = {
domainName,
error: {
message: res.statusText,
}
};
}
} catch(e) {
output[domainName] = {
domainName,
error: {
name: e.name,
message: e.message,
}
};
}
}
(async () => {
for(const domain of domainList) {
console.log('Fetching data for', domain);
await getWhoisData(domain);
console.log('Data for', domain, 'fetched !');
}
fs.writeFileSync('domainData.json', JSON.stringify(output));
})();