You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

from DrissionPage import ChromiumPage
from DrissionPage.common import *
from collections import *
import json
from single_course import one_course
from loguru import logger
def kill_course(again: bool = False):
# 统计课程完成情况
cnt = defaultdict(list)
# 读取课程信息
info = json.load(open('course_info.json', 'r'))
# 统计各个类别的课程 = 100的数量
cnt2 = Counter(info[k]['type']
for k in info.keys() if info[k]['rate'] == 100)
for k, v in info.items():
if v['rate'] < 100 and cnt2[v['type']] < 10:
cnt[v['type']].append((k, v['rate'])) # 课程类型作为键课程id作为值
logger.info('{}'.format(cnt))
if not cnt:
logger.info('所有课程均已完成')
return
# 按必修-选秀-专题-培训执行刷课
must = cnt['必修']
elective = cnt['选修']
special = cnt['专题']
train = cnt['培训']
while must or elective or special or train:
if must:
course_info = must.pop()
logger.info('当前刷课序号:{}'.format(course_info[0]))
one_course(course_info[0], '必修', course_info[1], again=again)
if elective:
course_info = elective.pop()
logger.info('当前刷课序号:{}'.format(course_info[0]))
one_course(course_info[0], '选修', course_info[1], again=again)
if special:
course_info = special.pop()
logger.info('当前刷课序号:{}'.format(course_info[0]))
one_course(course_info[0], '专题', course_info[1], again=again)
if train:
course_info = train.pop()
logger.info('当前刷课序号:{}'.format(course_info[0]))
one_course(course_info[0], '培训', course_info[1], again=again)
if __name__ == '__main__':
kill_course()