python ip location lookup

Solutions on MaxInterview for python ip location lookup by the best coders in the world

showing results for - "python ip location lookup"
Sergio
06 Jan 2019
1import re
2import json
3from urllib2 import urlopen
4
5url = 'http://ipinfo.io/json'
6response = urlopen(url)
7data = json.load(response)
8
9IP=data['ip']
10org=data['org']
11city = data['city']
12country=data['country']
13region=data['region']
14
15print 'Your IP detail\n '
16print 'IP : {4} \nRegion : {1} \nCountry : {2} \nCity : {3} \nOrg : {0}'.format(org,region,country,city,IP)
17