|
|
# example.py
|
|
|
import base64
|
|
|
import os
|
|
|
import sys
|
|
|
from pprint import pprint
|
|
|
import sys
|
|
|
|
|
|
from zfn_api import Client
|
|
|
|
|
|
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf-8', buffering=1)
|
|
|
|
|
|
cookies = {}
|
|
|
base_url = 'http://jwgl.cauc.edu.cn'
|
|
|
raspisanie = []
|
|
|
ignore_type = []
|
|
|
detail_category_type = []
|
|
|
timeout = 5
|
|
|
|
|
|
stu = Client(cookies=cookies, base_url=base_url, raspisanie=raspisanie, ignore_type=ignore_type, detail_category_type=detail_category_type, timeout=timeout)
|
|
|
|
|
|
if cookies == {}:
|
|
|
lgn = stu.login(input(), input())
|
|
|
if lgn["code"] == 1001:
|
|
|
verify_data = lgn["data"]
|
|
|
with open(os.path.abspath("kaptcha.png"), "wb") as pic:
|
|
|
pic.write(base64.b64decode(verify_data.pop("kaptcha_pic")))
|
|
|
verify_data["kaptcha"] = input("输入验证码:")
|
|
|
ret = stu.login_with_kaptcha(**verify_data)
|
|
|
if ret["code"] != 1000:
|
|
|
pprint(ret)
|
|
|
sys.exit()
|
|
|
pprint(ret)
|
|
|
elif lgn["code"] != 1000:
|
|
|
pprint(lgn)
|
|
|
sys.exit()
|
|
|
|
|
|
# result = stu.get_info('210340156') # 获取个人信息
|
|
|
# # result = stu.get_grade(2021, 2) # 获取成绩信息,若接口错误请添加 use_personal_info=True,只填年份获取全年
|
|
|
# result = stu.get_schedule(2022, 2) # 获取课程表信息
|
|
|
# # result = stu.get_academia() # 获取学业生涯数据
|
|
|
# # result = stu.get_notifications() # 获取通知消息
|
|
|
result = stu.get_selected_courses(int(input()), int(input())) # 获取已选课程信息
|
|
|
# # result = stu.get_block_courses(2021, 1, 1) # 获取选课板块课列表
|
|
|
pprint(result)
|
|
|
|
|
|
# # file_result = stu.get_academia_pdf()["data"] # 获取学业生涯(学生成绩总表)PDF文件
|
|
|
# file_result = stu.get_schedule_pdf(2022, 1)["data"] # 获取课程表PDF文件
|
|
|
# with open(os.path.abspath("preview.pdf"), "wb") as f:
|
|
|
# f.write(file_result) |