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, is there a website which has an API?
geolocationiprubyshell-script
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, is there a website which has an API?
Best Answer
You could use the http://ipinfo.io API for this:
If you're only interested in one field you can add that to the URL to get it as plain text:
If you're looking for a python module https://github.com/juanpabloaj/pyipinfo is a simple wrapper, or http://geocoder.readthedocs.org/en/stable/ is more fully featured and has built in support for ipinfo.io and other providers.