Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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'))
|
||||
2
main.py
2
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)
|
||||
|
||||
Reference in New Issue
Block a user