加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Cricket_score.py 844 Bytes
一键复制 编辑 原始数据 按行查看 历史
manitajay 提交于 2020-10-02 22:08 . Update Cricket_score.py
from urllib import request
import os
import pyttsx3
import bs4 # Beautiful Soup for Web Scraping
from win10toast import ToastNotifier
toaster = ToastNotifier()
#url from where we extrat data
url = "http://www.cricbuzz.com/cricket-match/live-scores"
sauce = request.urlopen(url).read()
soup = bs4.BeautifulSoup(sauce, "lxml")
score = []
results = []
for div_tags in soup.find_all('div', attrs={"class": "cb-lv-scrs-col text-black"}):
score.append(div_tags.text)
for result in soup.find_all('div', attrs={"class": "cb-lv-scrs-col cb-text-complete"}):
results.append(result.text)
engine = pyttsx3.init()
# testing
engine.say("match score and result is")
print(score[0], results[0])
toaster.show_toast(title=score[0], msg=results[0])
engine.runAndWait()
# initialisation
#after my update now this program speaks
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化