Archive

Posts Tagged ‘geo’

Locate by IP

Problem
You have an IP address and you want to get more info about it.

Solution
infoSNIPER does the job. However, I didn’t find an API to it.

MaxMind offers several services. They also have a free service called GeoLite, which is a bit less accurate and the databases are updated once a month. If you want to use it from Python, here is an API (pygeoip) to the databases (that you need to download and extract and they take about 44 MB disk space).

If you don’t want to download any databases then IPInfoDB can be a nice solution. They have an API, thus you can use this service in your applications. You’ll have to register for a free API key. There is a Python library to it called pyipinfodb.

Categories: python Tags: ,

IP to Country

Problem
Having an IP address, how to figure out where (in which country) it is located?

Solution
There are several sites that provide all kinds of information about a host (e.g. Geotool, GeoBytes, etc). We could write a scraper but there are some problems with this approach: some sites limit the number of free accesses (e.g. Geotool presents a captcha after a while); if the layout changes, you need to rewrite the scraper.

It would be better to use a web service. That’s how I found geoPlugin, which provides some free web services, including JSON too.

Examples:

I made a simple Python script for it, available here.

Offline solution
If high accuracy is not a concern, MaxMind’s free databases (Country / City) could offer an off-line solution. It has a Python API.” — Avaris

Credits
Thanks to Ashwini Chaudhary who pointed me towards geoPlugin.

Categories: python Tags: ,
Follow

Get every new post delivered to your Inbox.

Join 62 other followers