阿里云函数计算&校趣多疫情打卡
本文最后更新于 881 天前,其中的信息可能已经有所发展或是发生改变。

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表达式格式:秒 分 时 星期 日 月

4. 函数编写完成,查看执行日志

转载请注明出处!本文链接: https://battlehawk233.cn/post/64.html



评论

  1. 111
    Windows Edge 97.0.1072.76
    2年前
    2022-2-01 20:00:47

    这个好像不能用了吧

    • 博主
      111
      Windows Chrome 97.0.4692.99
      2年前
      2022-2-01 20:24:28

      可以用的

      • 111
        BATTLEHAWK
        Windows Edge 97.0.1072.76
        2年前
        2022-2-02 9:18:34

        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

        • 博主
          111
          Windows Chrome 97.0.4692.99
          2年前
          2022-2-02 13:42:13

          需要使用抓包工具对校趣多接口中的openid进行抓取 填入json中

          • 111
            BATTLEHAWK
            iPad Safari 14.0
            2年前
            2022-2-02 15:15:27

            早上抓到了
            OK了
            谢谢

发送评论编辑评论

|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇