Skip to content

Commit

Permalink
Fix:Repair cannot be completed
Browse files Browse the repository at this point in the history
  • Loading branch information
Coaixy committed Aug 7, 2024
1 parent 8baf8ad commit 228d312
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions WeiBanHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,15 @@ def start(self, courseId):
# https://github.com/Sustech-yx/WeiBanCourseMaster
def finish(self, courseId, finishId):
get_url_url = "https://weiban.mycourse.cn/pharos/usercourse/getCourseUrl.do"
finish_url = "https://weiban.mycourse.cn/pharos/usercourse/v1/{}.do"
finish_url = "https://weiban.mycourse.cn/pharos/usercourse/v2/{}.do"
data = {
"userProjectId": self.userProjectId,
"tenantCode": self.tenantCode,
"userId": self.userId,
"courseId": courseId,
}
raw_data = requests.post(get_url_url, data=data, headers=self.headers)
url = json.loads(raw_data.text.encode().decode("unicode-escape"))["data"]
token = url[url.find("methodToken="): url.find("&csCom")].replace(
"methodToken=", ""
)
# print(token)
requests.post(get_url_url, data=data, headers=self.headers)
token = self.get_method_token(finishId)
finish_url = finish_url.format(token)
ts = self.__get_timestamp().replace(".", "")
param = {
Expand All @@ -206,8 +202,33 @@ def finish(self, courseId, finishId):
"_": str(int(ts) + 1),
}
text = requests.get(finish_url, params=param, headers=self.headers).text
print(text)
return text

def get_method_token(self, course_id):
url = "https://weiban.mycourse.cn/pharos/usercourse/getCaptcha.do"
params = {
"userCourseId": course_id,
"userProjectId": self.userProjectId,
"userId": self.userId,
"tenantCode": "32101701"
}
text = requests.get(url, headers=self.headers, params=params).text
question_id = json.loads(text)['captcha']['questionId']
url = "https://weiban.mycourse.cn/pharos/usercourse/checkCaptcha.do"
params = {
"userCourseId": course_id,
"userProjectId": self.userProjectId,
"userId": self.userId,
"tenantCode": self.tenantCode,
"questionId": question_id
}
data = {
"coordinateXYs": "[{\"x\":199,\"y\":448},{\"x\":241,\"y\":466},{\"x\":144,\"y\":429}]"
}
text = requests.post(url, headers=self.headers, params=params, data=data).text
return json.loads(text)['data']['methodToken']

@staticmethod
def get_project_id(user_id, tenant_code, token: str) -> str:
url = "https://weiban.mycourse.cn/pharos/index/listMyProject.do"
Expand Down

0 comments on commit 228d312

Please sign in to comment.