|
| 1 | +from urllib.request import urlopen,Request |
| 2 | +from bs4 import BeautifulSoup |
| 3 | +from win10toast import ToastNotifier |
| 4 | +import time |
| 5 | + |
| 6 | +URL = 'http://www.cricbuzz.com/cricket-match/live-scores' |
| 7 | + |
| 8 | + |
| 9 | +def notify(title,score): |
| 10 | + # Function for Windows toast desktop notification |
| 11 | + toaster = ToastNotifier() |
| 12 | + # toaster.show_toast(score, "Get! Set! GO!", duration=5,icon_path='cricket.ico') |
| 13 | + toaster.show_toast("CRICKET LIVE SCORE",score, duration=30,icon_path='ipl.ico') |
| 14 | + |
| 15 | +while True: |
| 16 | + request = Request(URL,headers={'User-Agent': 'XYZ/3.0'}) |
| 17 | + response = urlopen(request,timeout=20).read() |
| 18 | + data_content = response |
| 19 | + # print(data_content) |
| 20 | + |
| 21 | + # page = urlopen(URL) |
| 22 | + soup = BeautifulSoup(data_content,'html.parser') |
| 23 | + |
| 24 | + update=[] |
| 25 | + # print(soup) |
| 26 | + # print(soup.find_all('div',attrs={'class':'cb-col cb-col-100 cb-plyr-tbody cb-rank-hdr cb-lv-main'})) |
| 27 | + for score in soup.find_all('div',attrs={'class':'cb-col cb-col-100 cb-plyr-tbody cb-rank-hdr cb-lv-main'}): |
| 28 | + # print(score) |
| 29 | + header = score.find('div',attrs={'class':'cb-col-100 cb-col cb-schdl'}) |
| 30 | + header=header.text.strip() |
| 31 | + |
| 32 | + status = score.find('div',attrs={'class':'cb-scr-wll-chvrn cb-lv-scrs-col'}) |
| 33 | + s=status.text.strip() |
| 34 | + |
| 35 | + notify(header,s) |
| 36 | + time.sleep(10) |
0 commit comments