Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python get city name from IP

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
 '
print 'IP : {4} 
Region : {1} 
Country : {2} 
City : {3} 
Org : {0}'.format(org,region,country,city,IP)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #city #IP
ADD COMMENT
Topic
Name
8+8 =