0

I want to figure out where a host is located, in which country. There are sites that look up this information (e.g. http://geoip.flagfox.net/). Before writing a scraper, I would like to ask if you know a python API for this task.

Update: following the link of Ashwini Chaudhary, I made my own ip2country converter. Available here.

Jabba
  • 19,598
  • 6
  • 52
  • 45

3 Answers3

1

Try this:

http://netsekure.org/wp-content/uploads/ip2loc.py

run this script from command prompt : python ip2loc.py all

Ashwini Chaudhary
  • 244,495
  • 58
  • 464
  • 504
  • Thanks, the "geoplugin" part works fine. geoplugin has some nice [web services](http://www.geoplugin.com/webservices) too, including JSON. – Jabba May 01 '12 at 11:00
1

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
  • 35,883
  • 7
  • 81
  • 72
0

You can try this

http://www.hostip.info/

Its very easy with this like below

import urllib
response = urllib.urlopen('http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true').read()
print(response)
Mirage
  • 30,868
  • 62
  • 166
  • 261