Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
账号密码错误时退出
  • Loading branch information
ter-s committed Nov 29, 2021
1 parent 1e4b82a commit 6a6becc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
url = ''
ua = os.getenv('UA',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36 Edg/80.0.361.111')
for _ in range(10):
try_time = 0
while try_time < 4:
try:
bjySession = requests.session()
bjySession.timeout = 5 # set session timeout
Expand All @@ -42,9 +43,13 @@
'Login[password]': login_password,
'Login[verifyCode]': cap_text
})
if login_r.text == '8':
raise Exception('Login:识别的验证码错误')
print(f'Login:[{login_r.status_code}]{login_r.text}')
if login_r.text == '8':
print('Login:识别的验证码错误')
continue
if 'fail' in login_r.text:
try_time += 9
raise Exception('Login:账号密码错误')
r = json.loads(bjySession.get("https://m.bjyouth.net/dxx/index").text)
if 'newCourse' not in r:
print(r)
Expand All @@ -54,6 +59,7 @@
break
except:
time.sleep(3)
try_time += 1
print(traceback.format_exc())

if not url:
Expand Down

0 comments on commit 6a6becc

Please sign in to comment.