Skip to main content

ustc jwxt api, for study only

Project description

ustcjwxt-python-lib

ustc jwxt api, for study only

Installation

pip install ustcjwxt

Structure

  • log
    实现了一个简单的日志系统
  • request_info
    记录了一些 requests 需要使用的信息
  • session
    可以登录到教务系统,并提供 StudentSession 类,用于存储登录信息
  • score
    可以获取学生的成绩
    当前功能: 获取成绩列表,计算 GPA / 加权平均分 / 算术平均分
  • course_select
    可以进行选课 / 退课操作

Usage

simple sample

from ustcjwxt import log
from ustcjwxt.session import StudentSession
from ustcjwxt.score import *

log.set_logger_level('DEBUG')

# login
s = StudentSession()
s.login_with_password(sys.argv[1], sys.argv[2])
print(s.get_cookies())

# get basic info
print(s.get_student_info())
with open('avatar.jpg', 'wb') as f:
    f.write(s.get_student_avatar())

# get score
gradeList = get_gradeList_all(s)
print(grade_calcGpa(gradeList))
print(grade_calcWeightedScore(gradeList))
print(grade_calcArithmeticScore(gradeList))

course operation sample

import sys
from ustcjwxt import log
from ustcjwxt.session import StudentSession
from ustcjwxt.course_select import *


s = StudentSession()
s.login_with_password(sys.argv[1], sys.argv[2])

# 退课: IS4001.01
result = drop_Lesson(s, 'IS4001.01')
if result['success']:
    print('课程已退')
else:
    print(f'课程未退成功 (报错信息:{result["errorMessage"]["textZh"]})')
# 选课: IS4001.01
if check_courseAvailable(s, 'IS4001.01'):
    print('课程可选')
    result = add_Lesson(s, 'IS4001.01')
    if result['success']:
        print('课程已选中')
    else:
        print(f'课程未选中 (报错信息:{result["errorMessage"]["textZh"]})')
else:
    print('课程不可选 (人员已满)')

课程交易

import sys, time
from ustcjwxt.session import StudentSession
from ustcjwxt.course_select import *

courseCode = 'IS4001.01'
s_give = StudentSession()
s_give.login_with_password('PB********', '********')
s_get = StudentSession()
s_get.login_with_password('PB********', '********')

# 预加载数据,减小延迟
load_cache(s_give)
load_cache(s_get)

time.sleep(1)

drop_Lesson(s_give, courseCode, delay_ms=0)
add_Lesson(s_get, courseCode, delay_ms=0)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ustcjwxt-0.2.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ustcjwxt-0.2.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file ustcjwxt-0.2.0.tar.gz.

File metadata

  • Download URL: ustcjwxt-0.2.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for ustcjwxt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 248117c9a336a06e19a0aca72be153829c6eeb2bf77aaf03c4cdc2e3be621e57
MD5 2442a60dc80bcea3eac0097160da9b2c
BLAKE2b-256 7c384b4a3dbd877a5f1282c03b9f99e0c81058648e48d85e7db1f155f24b4fe0

See more details on using hashes here.

File details

Details for the file ustcjwxt-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ustcjwxt-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for ustcjwxt-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c061de0465360d209024a18e196895fb9fad027fbb82a66c51ffd0aaad521eb
MD5 aa2a4101207d1fc8bd23827f3364463c
BLAKE2b-256 801a6b246abe3601f420ab4f3e8bd2a0c444d436cc51f851be2539bf786ef496

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page