Skip to content

Instantly share code, notes, and snippets.

@picatz
Created November 12, 2016 22:11
Show Gist options
  • Save picatz/b920216e182fb13d0e38c7045aa19382 to your computer and use it in GitHub Desktop.
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.
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