Conditions | 7 |
Total Lines | 20 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
35 | def main(self): |
||
36 | msg = "" |
||
37 | try: |
||
38 | res = requests.get("https://news.topurl.cn/api").json() |
||
39 | if res.get("code") == 200: |
||
40 | data = res.get("data") |
||
41 | if data.get("newsList"): |
||
42 | msg += "📮 每日新闻 📮\n" |
||
43 | for no, news_ in enumerate(data.get("newsList"), start=1): |
||
44 | msg += f'{str(no).zfill(2)}. <a href="{news_.get("url")}">{news_.get("title")}</a>\n' |
||
45 | if data.get("historyList"): |
||
46 | msg += "\n🎬 历史上的今天 🎬\n" |
||
47 | for history in data.get("historyList"): |
||
48 | msg += f'{history.get("event", "")}\n' |
||
49 | msg += "\n🧩 天天成语 🧩\n" + self.parse_data(data, "phrase") |
||
50 | msg += "\n🎻 慧语香风 🎻\n" + self.parse_data(data, "sentence") |
||
51 | msg += "\n🎑 诗歌天地 🎑\n" + self.parse_data(data, "poem") |
||
52 | except Exception: |
||
53 | msg += f"每日新闻: 异常 {traceback.format_exc()}" |
||
54 | return msg |
||
55 | |||
63 |