加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cricket_news.py 719 Bytes
一键复制 编辑 原始数据 按行查看 历史
from bs4 import BeautifulSoup
import requests
import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
url = 'https://www.cricbuzz.com/cricket-news/latest-news'
ans = requests.get(url)
soup = BeautifulSoup(ans.content, 'html.parser')
anchors = soup.find_all('a', class_='cb-nws-hdln-ancr text-hvr-underline')
i = 1
speak('Welcome to sports news headlines!')
for anchor in anchors:
speak(anchor.get_text())
i+=1
if i==11:
break;
speak('Moving on next sports headline..')
speak('These all are major headlines, have a nice day SIR')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化