Skip to content

Instantly share code, notes, and snippets.

@kgourgou
Created November 9, 2016 02:39
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 kgourgou/9d9956655027e0bcb881d2f3d5af46a8 to your computer and use it in GitHub Desktop.
Save kgourgou/9d9956655027e0bcb881d2f3d5af46a8 to your computer and use it in GitHub Desktop.
For people that are bored of the sensationalism of the media and just want the cold, hard, fact.
"""
A hilary-endorsing script that loads the predictions from the NYT.
"""
import requests
from dateutil.parser import parse
# election forecast link
url = "https://intf.nyt.com/newsgraphics/2016/11-08-election-forecast/president.json"
req = requests.get(url)
data = req.json()
# load the probabilities
probs = data["president"]["current"]["win_prob"]
hilary = probs["clintonh"]
trump = probs["trumpd"]
when_is_this = parse(data["president"]["current"]["timestamp"])
print "As of",when_is_this.hour + 7,":",when_is_this.minute, "PM",
if trump>hilary:
print ", looks like we are screwed."
elif trump<hilary:
print ", looks like we are safe."
else:
print ", things look pretty even from here."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment