Created
November 12, 2016 22:11
-
-
Save picatz/b920216e182fb13d0e38c7045aa19382 to your computer and use it in GitHub Desktop.
Simple ip address information script to use as a demo for my python debugging blog post.
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
import sys | |
import requests | |
import json | |
# ip address is passed in as the first argument | |
ip = sys.argv[1] | |
# make a request to ipinfo.io containing the ip address | |
site_data = requests.get('http://ipinfo.io/' + ip).content | |
# parse the site data | |
json_data = json.loads(site_data) | |
# iterate and print the json data | |
for label, info in json_data.iteritems(): | |
print label + ': ' + info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment