Skip to content

Instantly share code, notes, and snippets.

@bkabrda
Created June 25, 2016 20:16
Show Gist options
  • Select an option

  • Save bkabrda/bc166034299fc9bf28afed5323c4822d to your computer and use it in GitHub Desktop.

Select an option

Save bkabrda/bc166034299fc9bf28afed5323c4822d to your computer and use it in GitHub Desktop.
import requests
p = requests.get('https://petition.parliament.uk/petitions/131215.json').json()
tuples = [(x['name'], x['signature_count'])
for x in p['data']['attributes']['signatures_by_country']]
tuples = sorted(tuples, key=lambda x: x[1])
counted = 0
for t in tuples:
counted += t[1]
print(t)
print('Signature count: {}'.format(p['data']['attributes']['signature_count']))
print('Counted: {}'.format(counted))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment