Skip to content

Instantly share code, notes, and snippets.

@BharatKalluri
Created February 15, 2017 12:17
Show Gist options
  • Save BharatKalluri/aaff0fc7af68de40802d921be203b4e9 to your computer and use it in GitHub Desktop.
Save BharatKalluri/aaff0fc7af68de40802d921be203b4e9 to your computer and use it in GitHub Desktop.
MatchScore Notification
import requests
from bs4 import BeautifulSoup
import subprocess
import time
def sendmessage(message):
subprocess.Popen(['notify-send', message])
return
def main():
inputUrl = input("Input the url to monitor: ")
if not 'http://' in inputUrl:
inputUrl = "http://" + inputUrl
timeBreak = input("Input the interval for which you want to be notified!(in seconds) : ")
html_doc = requests.get(inputUrl)
soup = BeautifulSoup(html_doc.content, "lxml")
homeScore = soup.find_all('div', {'class': 'home-score'})[0].text
awayScore = soup.find_all('div', {'class': 'away-score'})[0].text
homediv = soup.find_all('div', {'data-omniture-icid': 'HDH'})[0].h2.text
awaydiv = soup.find_all('div', {'data-omniture-icid': 'HDA'})[0].h2.text
while True:
sendmessage(homediv+" vs "+awaydiv + " Scores are " + homeScore+" "+awayScore)
time.sleep(int(timeBreak))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment