36 lines
1020 B
Python
36 lines
1020 B
Python
import os
|
|
import sys
|
|
import requests
|
|
|
|
PUNCH_URL = "https://m-zjt.kefang.net/api/zms/attendance/attendanceRecord/punchCourseByStudent"
|
|
|
|
|
|
def punch(attendance_id: str, token: str) -> requests.Response:
|
|
payload = {
|
|
"attendanceId": attendance_id
|
|
}
|
|
headers = {
|
|
"User-Agent": "Dart/3.6 (dart:io)",
|
|
"Accept-Encoding": "gzip",
|
|
"Cookie": f"token={token}"
|
|
}
|
|
return requests.put(PUNCH_URL, data=payload, headers=headers, verify=False)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# attendance_id from argv[1], else env ATTENDANCE_ID
|
|
attendance_id = (sys.argv[1] if len(sys.argv) >
|
|
1 else os.getenv("ATTENDANCE_ID"))
|
|
token = os.getenv("TOKEN", "48db6cdf9a2c4f58a189436cb5429659")
|
|
|
|
if not attendance_id:
|
|
print("缺少 attendanceId 内容,无法打卡")
|
|
raise SystemExit(1)
|
|
|
|
try:
|
|
resp = punch(attendance_id, token)
|
|
print(resp.text)
|
|
except Exception as e:
|
|
print(f"打卡失败: {e}")
|
|
raise SystemExit(1)
|