Last active
December 17, 2015 18:59
-
-
Save mwatts272/5657250 to your computer and use it in GitHub Desktop.
An easy means of getting a Users Geographic Data based from their Internet Protocol Address. Please Note: Please only use your public IP Address, and not your routers self assigned IP Address.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Retrieves Geographic Information (Location) of a specified IP Address | |
""" | |
import urllib | |
ipAddress = '50.57.97.17' | |
response = urllib.urlopen('http://www.geoplugin.net/json.gp?ip={0}' .format(ipAddress)).read() | |
""" | |
Result of str(response): | |
{ | |
"geoplugin_request":"50.57.97.17", | |
"geoplugin_status":200, | |
"geoplugin_credit":"Some of the returned data includes GeoLite data created by MaxMind, available from <a href=\\'http:\/\/www.maxmind.com\\'>http:\/\/www.maxmind.com<\/a>.", | |
"geoplugin_city":"San Antonio", | |
"geoplugin_region":"TX", | |
"geoplugin_areaCode":"210", | |
"geoplugin_dmaCode":"641", | |
"geoplugin_countryCode":"US", | |
"geoplugin_countryName":"United States", | |
"geoplugin_continentCode":"NA", | |
"geoplugin_latitude":"29.488899", | |
"geoplugin_longitude":"-98.398697", | |
"geoplugin_regionCode":"TX", | |
"geoplugin_regionName":"Texas", | |
"geoplugin_currencyCode":"USD", | |
"geoplugin_currencySymbol":"$", | |
"geoplugin_currencySymbol_UTF8":"$", | |
"geoplugin_currencyConverter":1 | |
} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment