Skip to content

Instantly share code, notes, and snippets.

@Abdisalan
Last active November 6, 2020 05:46
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 Abdisalan/3f39c9eaab31309049c6bf2143755893 to your computer and use it in GitHub Desktop.
Save Abdisalan/3f39c9eaab31309049c6bf2143755893 to your computer and use it in GitHub Desktop.
Get notified by ABC 2020 Election Results
import time
import os
import requests
from bs4 import BeautifulSoup
def get_results():
print("checking...")
page = requests.get(
"https://abcnews.go.com/Elections/2020-us-presidential-election-results-live-map/")
soup = BeautifulSoup(page.content, 'html.parser')
biden_count = int(soup.select(
'div.Candidate--democrat div.Candidate__Votes')[0].text)
trump_count = int(soup.select(
'div.Candidate--republican div.Candidate__Votes')[0].text)
if biden_count >= 270:
os.system('say Joe Biden projected to win the election.')
print("Biden wins")
elif trump_count >= 270:
os.system('say Donald Trump projected to win the election.')
print("Trump wins")
time.sleep(60*15) # 15 minutes
while True:
get_results()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment