In this script we are going to get live update from any website, i am using cricbuzz just for the purpose of this tutorial.
Requirements:
requests - Install Requests
BeautifulSoup - Install bs4 (search for installation instruction on page) -Web scrapping tools for python
Notify - To send update on desktop notification.
Use below script and save as .py file, call script with while loop and u will get update on timely manner.
###Script###
from bs4 import BeautifulSoup
from gi.repository import Notify
Notify.init("Test")
url="http://www.cricbuzz.com/cricket-match/live-scores"
r = requests.get(url)
soup = BeautifulSoup(r.content)
title = soup.find_all("div", {"class": "cb-col-50 cb-col cb-schdl"})
score = soup.find_all("div", {"class": "cb-col-50 cb-col"})
i=0
for x, y in zip(title, score):
if i >= 3:
break;
print y.contents[0].text
msg = x.contents[0].text.encode('ascii', 'ignore') + " " +y.contents[0].text.encode('ascii', 'ignore')
print msg
notice=Notify.Notification.new("Live-Scores", msg)
notice.show()
i+=1
No comments:
Post a Comment