Last active
February 2, 2020 05:59
-
-
Save fmasanori/b7b56cf9fb0a4a4e4a17 to your computer and use it in GitHub Desktop.
propublica.py
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
from urllib.request import Request, urlopen | |
import json | |
url = "https://api.propublica.org/campaign-finance/v1/2016/president/totals.json" | |
q = Request(url) | |
q.add_header('X-API-Key', 'n8QLPm4lNS2Mfak1bam5X7HlevBAOSoF9epQkX0m') | |
data = urlopen(q).read() | |
data = json.loads(data.decode('utf-8')) | |
for candidate in data['results']: | |
print (candidate['name']) | |
print (candidate['total_contributions']) | |
print (candidate['cash_on_hand']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment