How to find location with IP address in Python?

One of the simplest methods for getting the IP address as well as the location in detail is to use http://ipinfo.io

import re
import json
from urllib2 import urlopen

url="http://ipinfo.io/json"
response = urlopen(url)
data = json.load(response)

IP=data['ip']
org=data['org']
city = data['city']
country=data['country']
region=data['region']

print 'Your IP detail\n '
print 'IP : {4} \nRegion : {1} \nCountry : {2} \nCity : {3} \nOrg : {0}'.format(org,region,country,city,IP)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)