/
test.mjs
48 lines (37 loc) · 1.2 KB
/
test.mjs
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
import ip2locationio from "ip2location-io-nodejs";
let mykey = "YOUR_API_KEY";
// Configures IP2Location.io API key
let config = new ip2locationio.Configuration(mykey);
let ipl = new ip2locationio.IPGeolocation(config);
let myip = "8.8.8.8";
let lang = "en"; // language parameter is only available for Plus and Security plans
// Lookup ip address geolocation data
ipl.lookup(myip, lang)
.then((data) => {
// print the data in json format
console.log(data)
})
.catch((error) => {
// print the error
console.log(error)
});
let whois = new ip2locationio.DomainWhois(config);
let mydomain = "locaproxy.com";
// Lookup domain information
whois.lookup(mydomain)
.then((data) => {
// print the data in json format
console.log(data)
})
.catch((error) => {
// print the error
console.log(error)
});
// Convert normal text to punycode
console.log(whois.getPunycode("täst.de"));
// Convert punycode to normal text
console.log(whois.getNormalText("xn--tst-qla.de"));
// Get domain name from URL
console.log(whois.getDomainName("https://www.example.com/exe"));
// Get domain extension (gTLD or ccTLD) from URL or domain name
console.log(whois.getDomainExtension("example.com"));