某打卡软件自动化脚本

本文将通过腾讯云函数实现自动打卡,仅供交流学习代码思想,禁止用于商用以及其他用途。

0. 打开腾讯云

➡️ 点击直达

腾讯云

1. 点击免费注册

按照流程完成注册

免费注册

2. 完成个人实名认证

➡️ 实名认证

3. 打开云函数

➡️ 云函数

首次使用需要授权,按照指引点击即可

image-20210116113018044

4. 进入云函数,分别点击函数服务新建

函数服务

5. 自定义创建函数

image-20210116114329649

6. 函数处内容

其中需要自助填写的参数有:

  • username
  • password
  • home
  • location

location查看方式

location

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import requests
def main_handler(event, context):
session = requests.Session()
host = r"http://xuegong.qfnu.edu.cn:8080"
login_url = host + r"/authentication/login"
user_info_url = host + r"/info/current"
morning_url = host + r"/student/healthInfo/save"
output = ''

headers = {'user-agent': 'Dart/2.9 (dart:io)'}
user_info_json = [{
'username': '', # 学号
'password': '', # 密码
'type': 'student' # 默认为student勿动
}]
health_info = {
"home": "在家", # 在家/在校/其他
# 如下信息无需更改
"address": "",
"keepInHome": "否",
"keepInHomeDate": "null",
"keepInHomeReasonSite": "",
"contact": "否",
"contactType": "",
"infect": "否",
"infectType": "",
"infectDate": "",
"familyNCP": "否",
"familyNCPType": "",
"familyNCPDate": "",
"familyNCPRelation": "",
"cold": "否",
"fever": "否",
"feverValue": "",
"cough": "否",
"diarrhea": "否",
"homeInHubei": "否",
"arriveHubei": "无",
"travel": "无",
"remark": "无",
"submitCount": 1,
"contactDetail": "",
# 去智慧曲园客户端查看在线位置填入该处
"location": "",
"naDetection": "否",
"areaInfect": "否",
"areaInfectType": "",
"areaInfectDate": "",
"areaInfectNumber": "",
"contactAH": "否",
"contactAHDetail": "",
"outProvinceBack14": "未出省",
"naDetectionDate": "",
"pharynxResult": "",
"anusResult": "",
"saDetection": "否",
"lgMResult": "",
"lgGResult": "",
"saDetectionDate": ""
}

# # 登陆
for i in range(len(user_info_json)):
# print(user_info_json[i])
response_login = session.post(url=login_url,
json=user_info_json[i],
headers=headers)

# 用户信息
response_user_info = session.post(url=user_info_url, headers=headers)

headers = {
'user-agent': 'Dart/2.9 (dart:io)',
'authorization': session.cookies['syt.sessionId']
}

response_morning = session.post(url=morning_url,
json=health_info,
headers=headers)
if response_morning.json()['message'] == "成功":
log = "complete"
else:
log = "false"

if i == 0:
output += "[{ID:"+user_info_json[i]['username']+ ",Clock in the morning:"+log+ '},'
elif i < (len(user_info_json)-1):
output += "{ID:"+user_info_json[i]['username']+ ",Clock in the morning:"+log+ '},'
else:
output += "{ID:"+user_info_json[i]['username']+ ",Clock in the morning:"+log+'}]'

return output

7. 分别点击部署测试

image-20210116115600680

8. 查看执行摘要,如果执行成功,返回结果为complete,如果失败则为false

image-20210116115647718

9. 设置触发器

image-20210116115729009

10. 点击创建触发器

image-20210116115807804

11. 设置触发器

触发器

触发周期使用自定义触发器

常用的Cron表达式:

  • 每天九点打卡:
1
0 0 9 * * * *
  • 每天8,10点打卡
1
0 0 8,10 * * * *

更多:Cron表达式

附录:在校期间早中晚打卡

0. 云函数代码

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import requests
def main_handler(event, context):
session = requests.Session()
host = r"http://xuegong.qfnu.edu.cn:8080"
login_url = host + r"/authentication/login"
user_info_url = host + r"/info/current"
morning_url = host + r"/student/healthInfo/save"
output = ''

headers = {'user-agent': 'Dart/2.9 (dart:io)'}
user_info_json = [{
'username': '', # 学号
'password': '', # 密码
'type': 'student' # 默认为student勿动
}]
health_info = {
"home": "在校",
"address": "",
"keepInHome": "否",
"keepInHomeDate": "null",
"keepInHomeReasonSite": "",
"contact": "否",
"contactType": "",
"infect": "否",
"infectType": "",
"infectDate": "",
"familyNCP": "否",
"familyNCPType": "",
"familyNCPDate": "",
"familyNCPRelation": "",
"cold": "否",
"fever": "否",
"feverValue": "",
"cough": "否",
"diarrhea": "否",
"homeInHubei": "否",
"arriveHubei": "无",
"travel": "无",
"remark": "无",
"submitCount": 1,
"contactDetail": "",
"location": "山东省日照市东港区学林路158号",
"naDetection": "否",
"areaInfect": "否",
"areaInfectType": "",
"areaInfectDate": "",
"areaInfectNumber": "",
"contactAH": "否",
"contactAHDetail": "",
"outProvinceBack14": "未出省",
"naDetectionDate": "",
"pharynxResult": "",
"anusResult": "",
"saDetection": "否",
"lgMResult": "",
"lgGResult": "",
"saDetectionDate": ""
}

# # 登陆
for i in range(len(user_info_json)):
# print(user_info_json[i])
response_login = session.post(url=login_url,
json=user_info_json[i],
headers=headers)

# 用户信息
response_user_info = session.post(url=user_info_url, headers=headers)

headers = {
'user-agent': 'Dart/2.9 (dart:io)',
'authorization': session.cookies['syt.sessionId']
}

response_morning = session.post(url=morning_url,
json=health_info,
headers=headers)
if response_morning.json()['message'] == "成功":
log = "complete"
else:
log = "false"

if i == 0:
output += "[{ID:"+user_info_json[i]['username']+ ",Clock in the morning:"+log+ '},'
elif i < (len(user_info_json)-1):
output += "{ID:"+user_info_json[i]['username']+ ",Clock in the morning:"+log+ '},'
else:
output += "{ID:"+user_info_json[i]['username']+ ",Clock in the morning:"+log+'}]'

return output

PS:可无限添加用户数,格式

1
2
3
4
5
6
7
8
9
10
11
{
'username': '', # 学号
'password': '', # 密码
'type': 'student' # 默认为student勿动
},
{
'username': '', # 学号
'password': '', # 密码
'type': 'student' # 默认为student勿动
}
……

触发器:设置方法点击查看

0. 云函数代码

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
import requests
def main_handler(event, context):
session = requests.Session()
host = r"http://xuegong.qfnu.edu.cn:8080"
login_url = host + r"/authentication/login"
user_info_url = host + r"/info/current"
noon_url = host + r"/student/healthInfoNoon/save/中午/36.5"
output = ''

headers = {'user-agent': 'Dart/2.9 (dart:io)'}
user_info_json = [{
'username': '', # 学号
'password': '', # 密码
'type': 'student' # 默认为student勿动
}]

# # 登陆
for i in range(len(user_info_json)):
# print(user_info_json[i])
response_login = session.post(url=login_url,
json=user_info_json[i],
headers=headers)

# 用户信息
response_user_info = session.post(url=user_info_url, headers=headers)

headers = {
'user-agent': 'Dart/2.9 (dart:io)',
'authorization': session.cookies['syt.sessionId']
}

response_noon = session.post(url=noon_url, headers=headers)
if response_noon.json()['message'] == "成功":
log = "complete"
else:
log = "false"

if i == 0:
output += "[{ID:"+user_info_json[i]['username']+ ",Clock in the afternoon:"+log+ '},'
elif i < (len(user_info_json)-1):
output += "{ID:"+user_info_json[i]['username']+ ",Clock in the afternoon:"+log+ '},'
else:
output += "{ID:"+user_info_json[i]['username']+ ",Clock in the afternoon:"+log+'}]'
return output

PS:可无限添加用户数,格式

1
2
3
4
5
6
7
8
9
10
11
{
'username': '', # 学号
'password': '', # 密码
'type': 'student' # 默认为student勿动
},
{
'username': '', # 学号
'password': '', # 密码
'type': 'student' # 默认为student勿动
}
……

触发器:设置方法点击查看

0. 云函数代码

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
48
49
50
import requests


def main_handler(event, context):
session = requests.Session()
host = r"http://xuegong.qfnu.edu.cn:8080"
login_url = host + r"/authentication/login"
user_info_url = host + r"/info/current"
night_url = host + r"/student/healthInfoNoon/save/晚上/36.5"
output = ''

headers = {'user-agent': 'Dart/2.9 (dart:io)'}
user_info_json = [{
'username': '', # 学号
'password': '', # 密码
'type': 'student' # 默认为student勿动
}
]

# # 登陆
for i in range(len(user_info_json)):
# print(user_info_json[i])
response_login = session.post(url=login_url,
json=user_info_json[i],
headers=headers)

# 用户信息
response_user_info = session.post(url=user_info_url, headers=headers)

headers = {
'user-agent': 'Dart/2.9 (dart:io)',
'authorization': session.cookies['syt.sessionId']
}

response_night = session.post(url=night_url, headers=headers)
if response_night.json()['message'] == "成功":
log = "complete"
else:
log = "false"

if i == 0:
output += "[{ID:" + user_info_json[i][
'username'] + ",Clock in the night:" + log + '},'
elif i < (len(user_info_json) - 1):
output += "{ID:" + user_info_json[i][
'username'] + ",Clock in the night:" + log + '},'
else:
output += "{ID:" + user_info_json[i][
'username'] + ",Clock in the night:" + log + '}]'
return output

PS:可无限添加用户数,格式

1
2
3
4
5
6
7
8
9
10
11
{
'username': '', # 学号
'password': '', # 密码
'type': 'student' # 默认为student勿动
},
{
'username': '', # 学号
'password': '', # 密码
'type': 'student' # 默认为student勿动
}
……

触发器:设置方法点击查看

至此自动打卡设置完成