本文最后更新于 697 天前,其中的信息可能已经有所发展或是发生改变。
1.配置函数调用
2. 编写&上传代码
附上打卡脚本:
# -*- coding: utf-8 -*-
import logging
import datetime
import json
import os
import requests
# Made by BATTLEHAWK
# https://static.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"
tips = '''
必填项:
打卡点 checkPlace 格式:XX省-XX市-XX区
联系方式 contactMethod 格式:电话号码
居住地 livingPlace 格式:XX省-XX市-XX区
详细住址 livingPlaceDetail
打卡省份 checkPlaceProvince
打卡城市 checkPlaceCity
打卡县市区 checkPlaceArea
'''
# 获取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().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()
3. 配置定时触发器,实现定时打卡
注:这里cron表达式是UTC时间,等于北京时间-8h
cron表达式格式:秒 分 时 星期 日 月
这个好像不能用了吧
可以用的
FC Invoke Start RequestId: cc319005-98ee-4edf-a8c9-703cc2e527ef
2022-02-02T01:17:01.373Z cc319005-98ee-4edf-a8c9-703cc2e527ef [ERROR] 校趣多打卡失败!请检查配置文件是否填写正确!
FC Invoke End RequestId: cc319005-98ee-4edf-a8c9-703cc2e527ef
是按照你给的json格式写的 就是error
需要使用抓包工具对校趣多接口中的openid进行抓取 填入json中
早上抓到了
OK了
谢谢