Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
petition watcher
import requests
from time import sleep
url = ""
def get_count():
count = None
while True:
r = requests.get(url)
if r:
return r.json()['data']['attributes']['signature_count']
print("Could not reach petition site")
c = get_count()
print("{:,} signatures".format(c))
while True:
n = get_count()
print("{:,} signatures, {:,} new signatures in last minute".format(n, n-c))
c = n
import requests
url = ""
sbc = requests.get(url).json()['data']['attributes']['signatures_by_country']
for d in sbc:
print("{name}: {signature_count:,}".format(**d))
print("Total: {:,}".format(sum(d['signature_count'] for d in sbc)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.