Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import requests
zips = "59221, 73949, 86515, 42223, 86044, 84536, 97635, 02861, 71749, 81137, 63673, 88063, 89439".split(', ')
url = 'https://congress.api.sunlightfoundation.com/districts/locate?apikey=4356d7e2b68340a69fb9b5e156e9cd49&zip='
for z in zips:
r = requests.get(url + z).json()['results']
print z, r
59221 [{u'state': u'MT', u'district': 0}, {u'state': u'ND', u'district': 0}]
73949 [{u'state': u'OK', u'district': 3}, {u'state': u'TX', u'district': 13}]
86515 [{u'state': u'AZ', u'district': 1}, {u'state': u'NM', u'district': 3}]
42223 [{u'state': u'KY', u'district': 1}, {u'state': u'TN', u'district': 7}]
86044 [{u'state': u'AZ', u'district': 1}, {u'state': u'UT', u'district': 3}]
84536 [{u'state': u'AZ', u'district': 1}, {u'state': u'UT', u'district': 3}]
97635 [{u'state': u'OR', u'district': 2}, {u'state': u'CA', u'district': 1}]
02861 [{u'state': u'MA', u'district': 4}, {u'state': u'RI', u'district': 1}]
71749 [{u'state': u'AR', u'district': 4}, {u'state': u'LA', u'district': 4}]
81137 [{u'state': u'CO', u'district': 3}, {u'state': u'NM', u'district': 3}]
63673 [{u'state': u'IL', u'district': 12}, {u'state': u'MO', u'district': 8}]
88063 [{u'state': u'NM', u'district': 2}, {u'state': u'TX', u'district': 16}]
89439 [{u'state': u'NV', u'district': 2}, {u'state': u'CA', u'district': 1}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment