Home > python > IP to Country

IP to Country

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

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.


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

Thanks to Ashwini Chaudhary who pointed me towards geoPlugin.

Categories: python Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: