校趣多自动卡打。

配置函数调用

首先登陆阿里云,找到控制台-函数计算FC-创建服务,进入之后选择创建函数:

image-20220202161050787

然后配置基本设置:

image-20220202161319990

编写&上传代码

原作者写的打卡脚本:

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
93
94
95
96
97
98
99
100
101
102
# -*- coding: utf-8 -*-
import logging
import datetime
import json
import os
import requests

# Made by BATTLEHAWK
# https://battlehawk233.cn/
logger=logging.getLogger()
url = r"https://mps.zocedu.com/corona/submitHealthCheck/submit"
url_info = r"https://mps.zocedu.com/corona/submitHealthCheck/getCurrentInfo"
defaultjson = {
"data": {
"checkPlace": "",
"contactMethod": "",
"teacher": "",
"temperature": "36.5",
"isCohabitFever": "否",
"isLeavePalce": "否",
"beenPlace": "",
"isContactNcov": "否",
"livingPlace": "",
"livingPlaceDetail": "",
"name1": "",
"relation1": "",
"phone1": "",
"name2": "",
"relation2": "",
"phone2": "",
"remark": "",
"extraInfo": "[]",
"healthStatus": "z",
"emergencyContactMethod": "[]",
"checkPlacePoint": "124,37",
"checkPlaceDetail": "",
"checkPlaceCountry": "",
"checkPlaceProvince": "",
"checkPlaceCity": "",
"checkPlaceArea": "",
},
"other": {
"openid": ""
}
}
openid = ""
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat"
}
data = {}
jsonfile = "config.json"


def getSessionID():
url = "https://mps.zocedu.com/corona/submitHealthCheck"
res = requests.get(url, {
"openId": openid,
"latitude": "",
"longitude": ""
})
sessionid = res.cookies.get("JSESSIONID")
return sessionid


# 加载Json配置文件
def loadJson():
global data, openid
f = open(jsonfile, "r")
obj = json.load(f)
f.close()
data = obj["data"]
openid = obj["other"]["openid"]


# 打卡函数
def checkIn():
cookies = {
"JSESSIONID": getSessionID()
}
res = requests.post(url, data=data, headers=headers, cookies=cookies)
if res.text == "":
logger.info("校趣多打卡成功!当前时间:" + datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
else:
logger.error("校趣多打卡失败!请检查配置文件是否填写正确!")


# 创建配置文件
def createConfigFile():
global defaultjson
f = open(jsonfile, "w")
json.dump(defaultjson, f, ensure_ascii=False, indent=2)
f.close()

def handler(event, context):
if not os.path.exists(jsonfile):
createConfigFile()
logger.error("未检测到配置文件,请填写config.json后运行本打卡脚本!")
exit(0)
else:
loadJson()
checkIn()

详细说明:

  • 打卡点 checkPlace 格式:XX省-XX市-XX区
  • 联系方式 contactMethod 格式:电话号码
  • 居住地 livingPlace 格式:XX省-XX市-XX区
  • 详细住址 livingPlaceDetail
  • 打卡省份 checkPlaceProvince
  • 打卡城市 checkPlaceCity
  • 打卡县市区 checkPlaceArea

以上这些是必须要填写的,另外还有一个不能忽视:

1
2
3
"other": {
"openid": ""
}

这里是一定不能忘记的,要不然就会一直报错,这里需要用到抓包工具,我推荐一个抓包工具:Fiddler

获取openid

首先需要在电脑上登陆微信,找到校趣多的小程序:

image-20220202181253494

用电脑打卡一次,去找到路径:

image-20220202181541444

获取到自己openid以后就填写到代码当中去,这里最好先手动生成一下config.json,因为阿里云FC那个里面不知道是怎么回事,无法通过代码自动生成config.json

设置定时触发

image-20220203115927372

这里可以设置定时触发器,我设置的是上海时间每天早上六点自动打卡:CRON_TZ=Asia/Shanghai 0 0 6 * * *

修改版本

这里对原先的代码进行了一些修改,增添了以下功能:

  • 邮件发送

代码如下:

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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# -*- coding: utf-8 -*-
import logging
import datetime
import json
import os
import pytz
import smtplib
import requests
from email.mime.text import MIMEText
from email.header import Header

logger = logging.getLogger()

# 邮箱参数
sender = '' # 发送邮箱
pwd = '' # 邮箱smtp密码
server_host = '' # smtp地址
receiver = '' # 接收者

# post地址
url = r"https://mps.zocedu.com/corona/submitHealthCheck/submit"
url_info = r"https://mps.zocedu.com/corona/submitHealthCheck/getCurrentInfo"

# 生成json文件
defaultjson = {
"data": {
"checkPlace": "",
"contactMethod": "",
"teacher": "",
"temperature": "36.2",
"isCohabitFever": "否",
"isLeavePalce": "否",
"beenPlace": "",
"isContactNcov": "否",
"livingPlace": "",
"livingPlaceDetail": "",
"name1": "",
"relation1": "",
"phone1": "",
"name2": "",
"relation2": "",
"phone2": "",
"remark": "",
"extraInfo": "[]",
"healthStatus": "z",
"emergencyContactMethod": "[]",
"checkPlacePoint": "124,37",
"checkPlaceDetail": "",
"checkPlaceCountry": "",
"checkPlaceProvince": "",
"checkPlaceCity": "",
"checkPlaceArea": "",
},
"other": {
"openid": ""
}
}
openid = ""
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat"
}
data = {}
jsonfile = "config.json"


# 获取JSESSIONID
def getSessionID():
url = "https://mps.zocedu.com/corona/submitHealthCheck"
res = requests.get(url, {
"openId": openid,
"latitude": "",
"longitude": ""
})
sessionid = res.cookies.get("JSESSIONID")
return sessionid


# 加载Json配置文件
def loadJson():
global data, openid
f = open(jsonfile, "r")
obj = json.load(f)
f.close()
data = obj["data"]
openid = obj["other"]["openid"]


# 打卡函数
def checkIn():
cookies = {
"JSESSIONID": getSessionID()
}
res = requests.post(url, data=data, headers=headers, cookies=cookies)
if res.text == "":
logger.info("校趣多打卡成功!当前时间:" + datetime.datetime.now(pytz.timezone('PRC')).strftime("%Y-%m-%d %H:%M:%S"))
send_email()
else:
logger.error("校趣多打卡失败!请检查配置文件是否填写正确!")
send_error_email()


# 创建配置文件
def createConfigFile():
global defaultjson
f = open(jsonfile, "w")
json.dump(defaultjson, f, ensure_ascii=False, indent=2)
f.close()


def send_email():
global server
# 邮件内容
subject = '健康打卡已经完成!'
time = datetime.datetime.now(pytz.timezone('PRC')).strftime("%Y-%m-%d %H:%M")
sentence = '当前时间为:' + time + ',当天健康打卡已经完成!'
message = MIMEText(sentence, 'plain', 'utf-8')
message['Subject'] = Header(subject, 'utf-8')
message['From'] = sender

# 发送
try:
server = smtplib.SMTP_SSL(server_host)
server.connect(server_host, 465)
server.login(sender, pwd)
server.sendmail(sender, receiver, message.as_string())
print("邮件发送成功")
except smtplib.SMTPException:
print("Error: 无法发送邮件")
finally:
server.close()


def send_error_email():
global server
# 邮件内容
subject = '好像出错啦!'
time = datetime.datetime.now(pytz.timezone('PRC')).strftime("%Y-%m-%d %H:%M")
sentence = '当前时间为:' + time + ',当天未完成健康打卡,请手动打卡,错误信息见控制台。'
message = MIMEText(sentence, 'plain', 'utf-8')
message['Subject'] = Header(subject, 'utf-8')
message['From'] = sender

# 发送
try:
server = smtplib.SMTP_SSL(server_host)
server.connect(server_host, 465)
server.login(sender, pwd)
server.sendmail(sender, receiver, message.as_string())
print("邮件发送成功")
except smtplib.SMTPException:
print("Error: 无法发送邮件")
finally:
server.close()


def handler(event, context):
if not os.path.exists(jsonfile):
createConfigFile()
logger.error("未检测到配置文件,请填写config.json后运行本打卡脚本!")
exit(0)
else:
loadJson()
checkIn()

结果截图

image-20220202182901321


![image-20220202182916790](配置函数调用

首先登陆阿里云,找到控制台-函数计算FC-创建服务,进入之后选择创建函数:

image-20220202161050787

然后配置基本设置:

image-20220202161319990

编写&上传代码

原作者写的打卡脚本:

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
93
94
95
96
97
98
99
100
101
102
# -*- coding: utf-8 -*-
import logging
import datetime
import json
import os
import requests

# Made by BATTLEHAWK
# https://battlehawk233.cn/
logger=logging.getLogger()
url = r"https://mps.zocedu.com/corona/submitHealthCheck/submit"
url_info = r"https://mps.zocedu.com/corona/submitHealthCheck/getCurrentInfo"
defaultjson = {
"data": {
"checkPlace": "",
"contactMethod": "",
"teacher": "",
"temperature": "36.5",
"isCohabitFever": "否",
"isLeavePalce": "否",
"beenPlace": "",
"isContactNcov": "否",
"livingPlace": "",
"livingPlaceDetail": "",
"name1": "",
"relation1": "",
"phone1": "",
"name2": "",
"relation2": "",
"phone2": "",
"remark": "",
"extraInfo": "[]",
"healthStatus": "z",
"emergencyContactMethod": "[]",
"checkPlacePoint": "124,37",
"checkPlaceDetail": "",
"checkPlaceCountry": "",
"checkPlaceProvince": "",
"checkPlaceCity": "",
"checkPlaceArea": "",
},
"other": {
"openid": ""
}
}
openid = ""
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat"
}
data = {}
jsonfile = "config.json"


def getSessionID():
url = "https://mps.zocedu.com/corona/submitHealthCheck"
res = requests.get(url, {
"openId": openid,
"latitude": "",
"longitude": ""
})
sessionid = res.cookies.get("JSESSIONID")
return sessionid


# 加载Json配置文件
def loadJson():
global data, openid
f = open(jsonfile, "r")
obj = json.load(f)
f.close()
data = obj["data"]
openid = obj["other"]["openid"]


# 打卡函数
def checkIn():
cookies = {
"JSESSIONID": getSessionID()
}
res = requests.post(url, data=data, headers=headers, cookies=cookies)
if res.text == "":
logger.info("校趣多打卡成功!当前时间:" + datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
else:
logger.error("校趣多打卡失败!请检查配置文件是否填写正确!")


# 创建配置文件
def createConfigFile():
global defaultjson
f = open(jsonfile, "w")
json.dump(defaultjson, f, ensure_ascii=False, indent=2)
f.close()

def handler(event, context):
if not os.path.exists(jsonfile):
createConfigFile()
logger.error("未检测到配置文件,请填写config.json后运行本打卡脚本!")
exit(0)
else:
loadJson()
checkIn()

详细说明:

  • 打卡点 checkPlace 格式:XX省-XX市-XX区
  • 联系方式 contactMethod 格式:电话号码
  • 居住地 livingPlace 格式:XX省-XX市-XX区
  • 详细住址 livingPlaceDetail
  • 打卡省份 checkPlaceProvince
  • 打卡城市 checkPlaceCity
  • 打卡县市区 checkPlaceArea

以上这些是必须要填写的,另外还有一个不能忽视:

1
2
3
"other": {
"openid": ""
}

这里是一定不能忘记的,要不然就会一直报错,这里需要用到抓包工具,我推荐一个抓包工具:Fiddler

获取openid

首先需要在电脑上登陆微信,找到校趣多的小程序:

image-20220202181253494

用电脑打卡一次,去找到路径:

image-20220202181541444

获取到自己openid以后就填写到代码当中去,这里最好先手动生成一下config.json,因为阿里云FC那个里面不知道是怎么回事,无法通过代码自动生成config.json

设置定时触发

image-20220203115927372

这里可以设置定时触发器,我设置的是上海时间每天早上六点自动打卡:CRON_TZ=Asia/Shanghai 0 0 6 * * *

修改版本

这里对原先的代码进行了一些修改,增添了以下功能:

  • 邮件发送

代码如下:

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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# -*- coding: utf-8 -*-
import logging
import datetime
import json
import os
import pytz
import smtplib
import requests
from email.mime.text import MIMEText
from email.header import Header

logger = logging.getLogger()

# 邮箱参数
sender = '' # 发送邮箱
pwd = '' # 邮箱smtp密码
server_host = '' # smtp地址
receiver = '' # 接收者

# post地址
url = r"https://mps.zocedu.com/corona/submitHealthCheck/submit"
url_info = r"https://mps.zocedu.com/corona/submitHealthCheck/getCurrentInfo"

# 生成json文件
defaultjson = {
"data": {
"checkPlace": "",
"contactMethod": "",
"teacher": "",
"temperature": "36.2",
"isCohabitFever": "否",
"isLeavePalce": "否",
"beenPlace": "",
"isContactNcov": "否",
"livingPlace": "",
"livingPlaceDetail": "",
"name1": "",
"relation1": "",
"phone1": "",
"name2": "",
"relation2": "",
"phone2": "",
"remark": "",
"extraInfo": "[]",
"healthStatus": "z",
"emergencyContactMethod": "[]",
"checkPlacePoint": "124,37",
"checkPlaceDetail": "",
"checkPlaceCountry": "",
"checkPlaceProvince": "",
"checkPlaceCity": "",
"checkPlaceArea": "",
},
"other": {
"openid": ""
}
}
openid = ""
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat"
}
data = {}
jsonfile = "config.json"


# 获取JSESSIONID
def getSessionID():
url = "https://mps.zocedu.com/corona/submitHealthCheck"
res = requests.get(url, {
"openId": openid,
"latitude": "",
"longitude": ""
})
sessionid = res.cookies.get("JSESSIONID")
return sessionid


# 加载Json配置文件
def loadJson():
global data, openid
f = open(jsonfile, "r")
obj = json.load(f)
f.close()
data = obj["data"]
openid = obj["other"]["openid"]


# 打卡函数
def checkIn():
cookies = {
"JSESSIONID": getSessionID()
}
res = requests.post(url, data=data, headers=headers, cookies=cookies)
if res.text == "":
logger.info("校趣多打卡成功!当前时间:" + datetime.datetime.now(pytz.timezone('PRC')).strftime("%Y-%m-%d %H:%M:%S"))
send_email()
else:
logger.error("校趣多打卡失败!请检查配置文件是否填写正确!")
send_error_email()


# 创建配置文件
def createConfigFile():
global defaultjson
f = open(jsonfile, "w")
json.dump(defaultjson, f, ensure_ascii=False, indent=2)
f.close()


def send_email():
global server
# 邮件内容
subject = '健康打卡已经完成!'
time = datetime.datetime.now(pytz.timezone('PRC')).strftime("%Y-%m-%d %H:%M")
sentence = '当前时间为:' + time + ',当天健康打卡已经完成!'
message = MIMEText(sentence, 'plain', 'utf-8')
message['Subject'] = Header(subject, 'utf-8')
message['From'] = sender

# 发送
try:
server = smtplib.SMTP_SSL(server_host)
server.connect(server_host, 465)
server.login(sender, pwd)
server.sendmail(sender, receiver, message.as_string())
print("邮件发送成功")
except smtplib.SMTPException:
print("Error: 无法发送邮件")
finally:
server.close()


def send_error_email():
global server
# 邮件内容
subject = '好像出错啦!'
time = datetime.datetime.now(pytz.timezone('PRC')).strftime("%Y-%m-%d %H:%M")
sentence = '当前时间为:' + time + ',当天未完成健康打卡,请手动打卡,错误信息见控制台。'
message = MIMEText(sentence, 'plain', 'utf-8')
message['Subject'] = Header(subject, 'utf-8')
message['From'] = sender

# 发送
try:
server = smtplib.SMTP_SSL(server_host)
server.connect(server_host, 465)
server.login(sender, pwd)
server.sendmail(sender, receiver, message.as_string())
print("邮件发送成功")
except smtplib.SMTPException:
print("Error: 无法发送邮件")
finally:
server.close()


def handler(event, context):
if not os.path.exists(jsonfile):
createConfigFile()
logger.error("未检测到配置文件,请填写config.json后运行本打卡脚本!")
exit(0)
else:
loadJson()
checkIn()

结果截图

image-20220202182901321


image-20220202182916790)

本文采用CC-BY-SA-3.0协议,转载请注明出处
作者: Lee