json is a module that helps us use the JSON data format.
In [ ]:
requests is a third-party module for interacting with the Internet
In [ ]:
Set the URL of the data, which we've mirrored here on S3: https://s3.amazonaws.com/nicar17/pycar17/bill_track.json (You can find the original data here)
In [ ]:
Read the requests documentation for information. I promise it
isn't that scary.
http://docs.python-requests.org/en/latest/user/quickstart/#json-response-content
Request the data
In [ ]:
Since we know our data will be JSON, let's automatically convert it to a Python dict.
In [ ]:
-- OR --
If the network is down, we can use a local version of this file.
with open('bills.json', 'r') as f:
data = json.load(f)
json.dumps() is a way to print a Python dict in a more
human-readable way.
In [ ]: