Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I find a location such as city/state or country from an ip address?

Is there a ruby gem or python module to do this? Or if there is a website which has an API.

share|improve this question

3 Answers 3

You can go here...Any such service is only a rough estimate for ANY IP address, but this is what you are looking for.

http://www.geobytes.com/iplocator.htm (just enter the "IP Address to locate" and hit submit)

share|improve this answer
1  
I have a long list of ip addresses so I was hoping I would be able to do it through a script –  ed1t Jun 18 '11 at 18:45

If you want to see a geolocation from a website you are navigating easily, you should install Flagfox add-on for Firefox: you will se a flag near address bar and clicking, on it, more information (city, IP...).

Also, you can use http://geo.flagfox.net to see the same detais for any IP address or server name.

share|improve this answer

Hostip.info is an open-source project with the goal to build/maintain a database mapping IP addresses to cities. Their about page explains the data sources relied on to populate this database.

Using HostIP, there are two ways to get location data from an IP address:

They also have a well-designed and easy-to-use RESTFUL API: just pass in your ip address after the ip= in the GET request string):

import urllib

response = urllib.urlopen('http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true').read()

print(response)

Second, the Project Website also makes its complete database available for download.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.