baidu
This commit is contained in:
@@ -79,7 +79,7 @@ class News(object):
|
|||||||
return output
|
return output
|
||||||
|
|
||||||
def get_baidu_news(self):
|
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()
|
now = datetime.now()
|
||||||
current_date = now.strftime("%Y年%m月%d日")
|
current_date = now.strftime("%Y年%m月%d日")
|
||||||
@@ -97,10 +97,11 @@ class News(object):
|
|||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
post = response.json()
|
post = response.json()
|
||||||
str = post['data']
|
# 提取content列表
|
||||||
|
str = post['data']['cards'][0]['content']
|
||||||
# 遍历列表,并格式化每个字典的title, url,然后添加到output字符串中
|
# 遍历列表,并格式化每个字典的title, url,然后添加到output字符串中
|
||||||
for index, article in enumerate(str, start=1):
|
for index, article in enumerate(str, start=1):
|
||||||
title = article['title']
|
title = article['word']
|
||||||
# url = article['url']
|
# url = article['url']
|
||||||
# 使用f-string格式化字符串,并添加到output中
|
# 使用f-string格式化字符串,并添加到output中
|
||||||
output += f"{index}. : {title}\n"
|
output += f"{index}. : {title}\n"
|
||||||
@@ -123,8 +124,8 @@ class News(object):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
news = News()
|
news = News()
|
||||||
# print(news.get_baidu_news())
|
print(news.get_baidu_news())
|
||||||
# msg = "@水牛-分身 今日百度新闻"
|
# # msg = "@水牛-分身 今日百度新闻"
|
||||||
# q = re.sub(r"@.*?[\u2005|\s]", "", msg).replace(" ", "")
|
# # q = re.sub(r"@.*?[\u2005|\s]", "", msg).replace(" ", "")
|
||||||
# print(q)
|
# # print(q)
|
||||||
print(news.get_eng_news('nbc'))
|
# print(news.get_eng_news('nbc'))
|
||||||
@@ -39,10 +39,10 @@ logging:
|
|||||||
handlers: [console, info_file_handler, error_file_handler]
|
handlers: [console, info_file_handler, error_file_handler]
|
||||||
|
|
||||||
groups:
|
groups:
|
||||||
enable: [45317011307@chatroom] # 允许响应的群 roomId,大概长这样:2xxxxxxxxx3@chatroom
|
enable: [45317011307@chatroom,49571962306@chatroom] # 允许响应的群 roomId,大概长这样:2xxxxxxxxx3@chatroom
|
||||||
|
|
||||||
news:
|
news:
|
||||||
receivers: [45317011307@chatroom] # 定时新闻接收人(roomid 或者 wxid)
|
receivers: [45317011307@chatroom,49571962306@chatroom] # 定时新闻接收人(roomid 或者 wxid)
|
||||||
|
|
||||||
report_reminder:
|
report_reminder:
|
||||||
receivers: [] # 定时日报周报月报提醒(roomid 或者 wxid)
|
receivers: [] # 定时日报周报月报提醒(roomid 或者 wxid)
|
||||||
|
|||||||
2
main.py
2
main.py
@@ -50,7 +50,7 @@ def main(chat_type: int):
|
|||||||
# robot.onEveryTime("07:00", weather_report, robot=robot)
|
# robot.onEveryTime("07:00", weather_report, robot=robot)
|
||||||
|
|
||||||
# 每天 7:30 发送新闻
|
# 每天 7:30 发送新闻
|
||||||
robot.onEveryTime("08:30", robot.newsReport)
|
robot.onEveryTime("08:30", robot.newsBaiduReport)
|
||||||
|
|
||||||
# 每天 16:30 提醒发日报周报月报
|
# 每天 16:30 提醒发日报周报月报
|
||||||
# robot.onEveryTime("10:30", ReportReminder.remind, robot=robot)
|
# robot.onEveryTime("10:30", ReportReminder.remind, robot=robot)
|
||||||
|
|||||||
2
robot.py
2
robot.py
@@ -284,8 +284,8 @@ class Robot(Job):
|
|||||||
"2.#标题2" \
|
"2.#标题2" \
|
||||||
"分类使用--号进行分组" + news
|
"分类使用--号进行分组" + news
|
||||||
|
|
||||||
|
rsp = self.chat.get_answer(news)
|
||||||
for r in receivers:
|
for r in receivers:
|
||||||
rsp = self.chat.get_answer(news, r)
|
|
||||||
self.sendTextMsg(rsp, r)
|
self.sendTextMsg(rsp, r)
|
||||||
|
|
||||||
def newsEnReport(self,website) -> None:
|
def newsEnReport(self,website) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user