1.0.0 • Published 8 years ago
dbip v1.0.0
Get information about an IP address such as country, ISP, and timezone. First have a look at the following example and then continue to read how it works.
Example
Module dbip promises a Javascript object.
var dbip = require('dbip')
dbip('143.176.113.73').then(info => {
console.log(info)
})
Output
Variable info looks like this:
{
"IP Address": "143.176.113.73",
"Address type": "IPv4",
"ISP": "Svianned",
"Connection type": "Dsl",
"Organization": "Tele2 Nederland B.V.",
"Timezone": "Europe/Amsterdam (UTC+2)",
"Local time": "",
"Country": "Netherlands",
"State / Region": "Drenthe",
"District / County": "Assen",
"City": "Assen (Tele2)",
"Coordinates": "52.997, 6.56675"
}
How does it work?
Module dbip sends a HTTP request to https://db-ip.com using module request (simplified http request client) and then uses Cheerio (server side jQuery implementation) to find the DOM elements we need.
Disclaimer
As a developer you understand that IP geolocation lookups like this are not always accurate. Because the info object is extracted from a page DOM, the module may no longer work if the website changes its page structure. If that happens, send me an email and I will fix it. (jochemstoel(@)gmail.com)
Jochem Stoel
Involuntary public figure.