File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1+ import urllib2
2+ from urllib2 import urlopen
3+ import json
4+ import re
5+ import requests
6+ # Get Public IP
7+
8+
9+ def getPublicIP ():
10+ data = requests .get ('http://checkip.dyndns.com/' ).content
11+ return re .compile (r'Address: (\d+.\d+.\d+.\d+)' ).search (data ).group (1 )
12+
13+ IP = str (getPublicIP ())
14+
15+ # Get Location
16+ url = 'http://ipinfo.io/' + IP + '/json'
17+ response = urlopen (url )
18+ data = json .load (response )
19+ city = data ['city' ]
20+ region = data ['region' ]
21+ country = data ['country' ]
22+ location = data ['loc' ]
23+ org = data ['org' ]
24+
25+ # Print Extracted Details
26+ print "Your City : " + city
27+ print "Your Region : " + region
28+ print "Your Country : " + country
29+ print "Your Location : " + location
30+ print "Your ISP : " + org
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments