Created
November 9, 2016 04:18
-
-
Save naari3/24f224db3a0b16045d764ce2dcb707e5 to your computer and use it in GitHub Desktop.
2016presidentsokuhou.py
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 | |
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