Once a minute finds Cricket scores and sends them

PHOTO EMBED

Mon Feb 28 2022 08:41:04 GMT+0000 (Coordinated Universal Time)

Saved by @ghefley #python #love #life #fun

#!/usr/bin/env python2 
import requests 
from bs4 import BeautifulSoup 
import pynotify 
from time import sleep 
def sendmessage(title, message): 
    pynotify.init("Test") 
    notice = pynotify.Notification(title, message) 
    notice.show() 
    return 
url = "http://static.cricinfo.com/rss/livescores.xml" 
while True: 
    r = requests.get(url) 
    while r.status_code is not 200: 
            r = requests.get(url) 
    soup = BeautifulSoup(r.text) 
    data = soup.find_all("description") 
    score = data[1].text 
    sendmessage("Score", score) 
    sleep(60) 
content_copyCOPY

https://www.quora.com/What-are-some-cool-Python-tricks