Created
January 31, 2017 14:39
-
-
Save andylolz/a1c6a640e3ecfded854a4782abc6c61a to your computer and use it in GitHub Desktop.
This file contains 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
[This page intentionally left blank] |
This file contains 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 requests | |
anti_url = 'https://petition.parliament.uk/petitions/171928.json' | |
pro_url = 'https://petition.parliament.uk/petitions/178844.json' | |
anti_json = requests.get(anti_url).json() | |
pro_json = requests.get(pro_url).json() | |
anti_sigs = {x['ons_code']: x['signature_count'] for x in anti_json['data']['attributes']['signatures_by_constituency']} | |
pro_sigs = {x['ons_code']: x['signature_count'] for x in pro_json['data']['attributes']['signatures_by_constituency']} | |
for k, pro_count in pro_sigs.items(): | |
if anti_sigs[k] < pro_count: | |
print('There are more signatures for the pro petition in {}'.format(k)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment