From 184cf67be489e01a929cef050615634e130a0705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E4=BB=99?= <66102002+Shanxuns@users.noreply.github.com> Date: Sun, 31 Oct 2021 06:28:06 +0800 Subject: [PATCH] Update foreWork.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #修正,正则表达式,部分无法截取课程的问题 --- src/course/foreWork.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/course/foreWork.py b/src/course/foreWork.py index c55e73bb..47e7dfb6 100644 --- a/src/course/foreWork.py +++ b/src/course/foreWork.py @@ -134,7 +134,7 @@ def find_objectives(usernm, chapterids, course_id, session): resp = session.get(url, headers=header) try: content = str(json.loads(resp.text)['data'][0]['card']['data']).replace('"', '') - result = re.findall('{objectid:(.*?),.*?,_jobid:(.*?),', content) + result = re.findall('[{,]objectid:(.*?)[},].*?[{,]_jobid:(.*?)[},]', content) jobs[lesson_id] = result console.log('在章节{}中找到[yellow bold]{}[/yellow bold]个任务点'.format(lesson_id, len(result))) except Exception as e: