forked from OreosLab/checkinpanel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_motto.py
More file actions
38 lines (31 loc) · 795 Bytes
/
api_motto.py
File metadata and controls
38 lines (31 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
"""
cron: 30 7 * * *
new Env('每日一句');
"""
import json
import requests
from notify_mtr import send
from utils import get_data
class Motto:
@staticmethod
def main():
"""
从词霸中获取每日一句,带英文。
:return:
"""
response = requests.get(url="http://open.iciba.com/dsapi")
if response.status_code == 200:
res = json.loads(response.content.decode("utf-8"))
content = res["content"]
note = res["note"]
msg = f"{content}\n{note}\n"
else:
msg = ""
return msg
if __name__ == "__main__":
data = get_data()
motto = data.get("MOTTO")
if motto:
res = Motto().main()
send("每日一句", res)