Total Complexity | 2 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
2 | """ |
||
3 | cron: 30 7 * * * |
||
4 | new Env('每日一句'); |
||
5 | """ |
||
6 | |||
7 | import requests |
||
8 | |||
9 | from notify_mtr import send |
||
10 | from utils import get_data |
||
11 | |||
12 | |||
13 | class Motto: |
||
14 | @staticmethod |
||
15 | def main(): |
||
16 | """从词霸中获取每日一句,带英文 |
||
17 | |||
18 | :return: str |
||
19 | """ |
||
20 | response = requests.get("http://open.iciba.com/dsapi") |
||
21 | if response.status_code != 200: |
||
22 | return "" |
||
23 | res = response.json() |
||
24 | return f'{res["content"]}\n{res["note"]}\n' |
||
25 | |||
26 | |||
27 | if __name__ == "__main__": |
||
28 | _data = get_data() |
||
29 | motto = _data.get("MOTTO") |
||
30 | if motto: |
||
31 | result = Motto().main() |
||
32 | send("每日一句", result) |
||
33 |