Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to select subject 1 or subject 3 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions xuechebu_crack.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
USER_INFO_CORRECT = True


def get_unfinished_list(session):
def get_unfinished_list(session, subject_no = 1):
url = 'http://xcbapi.xuechebu.com/videoApi/video/GetChapterList?os=pc'

unfinished = []
Expand All @@ -18,8 +18,10 @@ def get_unfinished_list(session):
r = session.get(url)
data = get_response_data(r)

subject = data[0] # 科目1
# subject = data[1] # 科目3
if subject_no == 1: # 科目1
subject = data[0]
elif subject_no == 3: # 科目3
subject = data[1]
classes = subject['ClassList']

for a_class in classes:
Expand Down Expand Up @@ -101,6 +103,17 @@ def login(session, username, password):
print('登录失败: ' + str(e))
return False

def get_input_subject():
while True:
subject_no = input('选择学习科目1或者科目3(输入1或者3):')
if subject_no in ["1","3"]:
break
else:
print("请重新输入1或者3")
continue

return int(subject_no)


def get_response_data(response):
try:
Expand Down Expand Up @@ -131,6 +144,8 @@ def main():

session = requests.session()

subject_no = get_input_subject()

while True:
user = get_user()

Expand All @@ -146,7 +161,7 @@ def main():
print()
break

unfinished = get_unfinished_list(session)
unfinished = get_unfinished_list(session, subject_no)

print()

Expand Down Expand Up @@ -181,7 +196,7 @@ def get_user():
user = USER

while not (user and is_valid_username(user[0])):
username = input('请输入驾校帐号: ')
username = input('请输入驾校帐号(身份证或手机号): ')
password = getpass.getpass('请输入密码: ')
user = [username, password]

Expand Down