diff --git a/base/func_news.py b/base/func_news.py index 983e97c..b96be4c 100644 --- a/base/func_news.py +++ b/base/func_news.py @@ -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')) \ No newline at end of file + print(news.get_baidu_news()) + # # msg = "@水牛-分身 今日百度新闻" + # # q = re.sub(r"@.*?[\u2005|\s]", "", msg).replace(" ", "") + # # print(q) + # print(news.get_eng_news('nbc')) \ No newline at end of file diff --git a/main.py b/main.py index 75ec54d..2cf46ef 100644 --- a/main.py +++ b/main.py @@ -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) diff --git a/robot.py b/robot.py index fc93065..3038fc5 100644 --- a/robot.py +++ b/robot.py @@ -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: