User:Pedro Sá Couto/Prototyping 5th/IPdetails

From XPUB & Lens-Based wiki

Output

IP information –

IP: 145.24.131.42
Region: South Holland
Country: NL
City: South Holland

import re
import json
from urllib.request 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 ('IP information – \n ')

print('IP: ' + IP + '\n' + 'Region: ' + region + '\n' + 'Country: ' + country + '\n' + 'City: ' + region)