generated from xsk666/autopost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
47 lines (40 loc) · 1.28 KB
/
index.py
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
39
40
41
42
43
44
45
46
47
# coding=utf-8
import json
import os
import time
import requests
import post
import sign
def qq(text, desp):
qmsg = "你的key"
return requests.get("https://qmsg.zendee.cn/send/" + qmsg + "?msg=" + text + "\n\n" + desp).json()
if __name__ == '__main__':
date = time.strftime("%Y/%m/%d")
print("开始 " + date + " 的打卡任务\n")
# 读取用户列表
path = os.getcwd()
if path.find("main") == -1:
path += "/main"
allinfo = json.load(open(path + "/users.json",encoding="utf-8"))
text = '| 姓名 | 结果 |'
for item in allinfo:
name = item.get("name")
print("开始为 " + name + " 打卡...")
try:
# 获取用户cookie
cook = sign.login(item)
# print(cook)
if cook.find("错误") != -1:
raise Exception(cook)
# 获取返回的打卡结果
response = post.run(item, cook)
except Exception as e:
print("---为 " + name + " 打卡失败\n" + str(e))
response = "打卡失败"
# 为推送填写打卡信息
text += f" \n| {name} | {response} |"
print("打卡结束\n")
try:
qq(date + "\n自动打卡任务已完成", text)
except:
print("推送qq通知出错")