Skip to content

Instantly share code, notes, and snippets.

@naari3
Created November 9, 2016 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naari3/24f224db3a0b16045d764ce2dcb707e5 to your computer and use it in GitHub Desktop.
Save naari3/24f224db3a0b16045d764ce2dcb707e5 to your computer and use it in GitHub Desktop.
2016presidentsokuhou.py
import requests
import time
def get_result():
url = "http://elections.huffingtonpost.com/2016/results/president.json"
r = requests.get(url)
j = r.json()["summaries"]["president"]
return (j['nClintonElectoralVotes'], j['nTrumpElectoralVotes'])
def main():
pre_result = None
while True:
result = get_result()
if result != pre_result:
print("Hillary Clinton ({}) vs ({}) Donald Trump\a\a\a\a".format(*result), end="\r")
pre_result = result
time.sleep(60)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment