Skip to content

Instantly share code, notes, and snippets.

@andylolz
Created January 31, 2017 14:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andylolz/a1c6a640e3ecfded854a4782abc6c61a to your computer and use it in GitHub Desktop.
Save andylolz/a1c6a640e3ecfded854a4782abc6c61a to your computer and use it in GitHub Desktop.
[This page intentionally left blank]
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