Merge remote-tracking branch 'origin/master'

This commit is contained in:
liuwei
2025-02-05 11:15:41 +08:00
3 changed files with 11 additions and 10 deletions

View File

@@ -79,7 +79,7 @@ class News(object):
return output
def get_baidu_news(self):
url = "https://orz.ai/dailynews/?platform=baidu"
url = "https://top.baidu.com/api/board?platform=wise&tab=realtime"
# 获取当前日期和英文星期名
now = datetime.now()
current_date = now.strftime("%Y年%m月%d")
@@ -97,10 +97,11 @@ class News(object):
if response.status_code == 200:
post = response.json()
str = post['data']
# 提取content列表
str = post['data']['cards'][0]['content']
# 遍历列表并格式化每个字典的title, url然后添加到output字符串中
for index, article in enumerate(str, start=1):
title = article['title']
title = article['word']
# url = article['url']
# 使用f-string格式化字符串并添加到output中
output += f"{index}. : {title}\n"
@@ -123,8 +124,8 @@ class News(object):
if __name__ == "__main__":
news = News()
# print(news.get_baidu_news())
# msg = "@水牛-分身 今日百度新闻"
# q = re.sub(r"@.*?[\u2005|\s]", "", msg).replace(" ", "")
# print(q)
print(news.get_eng_news('nbc'))
print(news.get_baidu_news())
# # msg = "@水牛-分身 今日百度新闻"
# # q = re.sub(r"@.*?[\u2005|\s]", "", msg).replace(" ", "")
# # print(q)
# print(news.get_eng_news('nbc'))

View File

@@ -50,7 +50,7 @@ def main(chat_type: int):
# robot.onEveryTime("07:00", weather_report, robot=robot)
# 每天 7:30 发送新闻
robot.onEveryTime("08:30", robot.newsReport)
robot.onEveryTime("08:30", robot.newsBaiduReport)
# 每天 16:30 提醒发日报周报月报
# robot.onEveryTime("10:30", ReportReminder.remind, robot=robot)

View File

@@ -284,8 +284,8 @@ class Robot(Job):
"2.#标题2" \
"分类使用--号进行分组" + news
rsp = self.chat.get_answer(news)
for r in receivers:
rsp = self.chat.get_answer(news, r)
self.sendTextMsg(rsp, r)
def newsEnReport(self,website) -> None: