Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
Update main.py
  • Loading branch information
tianzhengs committed Oct 16, 2022
1 parent c4f4667 commit 64986ca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.idea/
/__pycache__/
/__pycache__/
local_only.py
7 changes: 3 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import time

from study import study

Expand Down Expand Up @@ -30,7 +31,7 @@ def getAccounts():


ua = os.getenv('UA',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.50')
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.42')

accounts = getAccounts()
print(f'账号数量:{len(accounts)}')
Expand All @@ -46,6 +47,4 @@ def getAccounts():
print('--Summary--')
print(f'成功:{successful},失败:{failed}')
if failed != 0:
raise Exception(f'有{failed}个失败!')

raise Exception('貌似自己这显示完成了,但实际上没有?建议自己检查下(尤其是有团支书账号可以看到情况的),然后可以在issue#31里反馈下')
raise Exception(f'有{failed}个失败!')
9 changes: 8 additions & 1 deletion study.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def study(username, password, ua):
orgID = '172442'
print(f"无法获取orgID")

nOrgID = int(bjySession.get('https://m.bjyouth.net/dxx/is-league').text)

if f"学习课程:《{title}》" in list(map(lambda x: x['text'], haveLearned['data'])):
print(f'{title} 在运行前已完成,退出')
return 1
Expand All @@ -87,12 +89,17 @@ def study(username, password, ua):
#
# end_img_url = f'https://h5.cyol.com/special/daxuexi/{result.group(1)}/images/end.jpg'
study_url = f"https://m.bjyouth.net/dxx/check"
r = bjySession.post(study_url, json={"id": str(courseId), "org_id": int(orgID)}) # payload
r = bjySession.post(study_url, json={"id": str(courseId), "org_id": int(nOrgID)}) # payload

if r.text:
print(f'Unexpected response: {r.text}')
return 0

haveLearned = bjySession.get(learnedInfo).json()

if int(orgID) != nOrgID:
raise Exception('组织id不匹配,如果看到这个请开个issue说下')

if f"学习课程:《{title}》" in list(map(lambda x: x['text'], haveLearned['data'])):
print(f'{title} 成功完成学习')
return 1
Expand Down

0 comments on commit 64986ca

Please sign in to comment.