Created
February 15, 2017 12:17
-
-
Save BharatKalluri/aaff0fc7af68de40802d921be203b4e9 to your computer and use it in GitHub Desktop.
MatchScore Notification
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 | |
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