-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
5,990 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
build | ||
dist | ||
__pycache__ | ||
*.spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,47 @@ | ||
# - | ||
# 安全微伴题库 | ||
|
||
写在前面的话:克隆项目到本地,你获取到的题目信息将会与`Wei-ban_Questions_Bank.json`合并。希望你能将更新后的题库[Pull requests](https://github.com/pooneyy/weibanQuestionsBank/pulls)提交到本仓库,在此表示万分感谢。 | ||
|
||
### 查看题库 | ||
|
||
[markdown](https://github.com/pooneyy/weibanQuestionsBank/blob/master/weibanQuestionBank.md)、[html](http://htmlpreview.github.io/?https://github.com/pooneyy/weibanQuestionsBank/blob/master/weibanQuestionBank.html) | ||
|
||
### 导入题库 | ||
|
||
- 方式一:通过输入账号信息直接获取账号作答记录 | ||
|
||
运行`importData.py`,输入账号信息即可,账号信息形如 | ||
|
||
```text | ||
{"token":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","userId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","tenantCode":"00000001","userProjectId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"} | ||
``` | ||
|
||
获取方式参考[pooneyy/weiban-tool: 安全微伴自动刷课助手 (github.com)](https://github.com/pooneyy/weiban-tool) | ||
|
||
- 方式二:通过现有的作答记录 | ||
|
||
- 作答记录形如[data.json](https://github.com/pooneyy/weibanQuestionsBank/blob/master/data.json),获取方式,登录[安全微伴](http://weiban.mycourse.cn/), | ||
|
||
- 点击进入课程详情,以“新生安全教育”为例 | ||
|
||
- 点击“考试安排” | ||
|
||
<img src="http://png.eot.ooo/i/2022/09/10/631cadd79c44f.png" alt="1.png" style="zoom:67%;" /> | ||
|
||
- 点击“考试记录” | ||
|
||
<img src="http://png.eot.ooo/i/2022/09/10/631cadd88c9cf.png" alt="2.png" style="zoom: 67%;" /> | ||
|
||
- 点击“作答明细” | ||
|
||
<img src="http://png.eot.ooo/i/2022/09/10/631cadd96605b.png" alt="3.png" style="zoom:67%;" /> | ||
|
||
- 浏览器进入开发者模式,复制响应文本,以UTF-8的编码方式保存为`data.json`: | ||
|
||
<img src="http://png.eot.ooo/i/2022/09/10/631cb1cb3f34d.png" alt="4.png" style="zoom: 67%;" /> | ||
|
||
- 运行`importOneReviewPaper.py` | ||
|
||
### 导出题库 | ||
|
||
运行`exportData.py`,按照提示操作。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import json | ||
import requests | ||
import time | ||
|
||
class Parse: | ||
headers = { 'x-token': "", | ||
"User-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Mobile Safari/537.36 Edg/103.0.1264.77" | ||
} | ||
def __init__(self, userConfig): | ||
self.userConfig = json.loads(userConfig) | ||
|
||
def getStudentNumber(self): | ||
url = f"https://weiban.mycourse.cn/pharos/my/getInfo.do?timestamp={int(time.time())}" | ||
data = { | ||
'tenantCode': self.userConfig.get('tenantCode'), | ||
'userId': self.userConfig.get('userId') | ||
} | ||
self.headers['x-token'] = self.userConfig.get('token') | ||
response = requests.post(url, data=data, headers=self.headers) | ||
text = response.text | ||
data = json.loads(text) | ||
return data['data']['studentNumber'] | ||
|
||
def getExamPlanId(self): | ||
'''返回一个列表,包含课程全部考试计划的 id''' | ||
url = f'https://weiban.mycourse.cn/pharos/exam/listPlan.do?timestamp={int(time.time())}' | ||
data = { | ||
'userProjectId': self.userConfig.get('userProjectId'), | ||
'tenantCode': self.userConfig.get('tenantCode'), | ||
'userId': self.userConfig.get('userId') | ||
} | ||
self.headers['x-token'] = self.userConfig.get('token') | ||
response = requests.post(url, data=data, headers=self.headers) | ||
text = response.text | ||
data = json.loads(text) | ||
examPlanIdList = [i['examPlanId'] for i in data['data']] | ||
return examPlanIdList | ||
|
||
def getUserExamId(self, examPlanIdList): | ||
'''返回一个列表,包含某一次考试全部试卷(重做试卷)的ID''' | ||
userExamIdList = [] | ||
url = f'https://weiban.mycourse.cn/pharos/exam/listHistory.do?timestamp={int(time.time())}' | ||
for examPlanId in examPlanIdList: | ||
data = { | ||
'examPlanId': examPlanId, | ||
'tenantCode': self.userConfig.get('tenantCode'), | ||
'userId': self.userConfig.get('userId'), | ||
'isRetake': 2 | ||
} | ||
self.headers['x-token'] = self.userConfig.get('token') | ||
response = requests.post(url, data=data, headers=self.headers) | ||
text = response.text | ||
data = json.loads(text) | ||
for i in data['data']: | ||
userExamIdList.append(i['id']) | ||
return userExamIdList | ||
|
||
def getPaperDetails(self, userExamIdList): | ||
'''返回一个列表,包含某一张试卷的详情''' | ||
userQuestionsBank = {} | ||
url = f'https://weiban.mycourse.cn/pharos/exam/reviewPaper.do?timestamp={int(time.time())}' | ||
for userExamId in userExamIdList: | ||
data = { | ||
'userExamId': userExamId, | ||
'isRetake': 2, | ||
'tenantCode': self.userConfig.get('tenantCode'), | ||
'userId': self.userConfig.get('userId') | ||
} | ||
self.headers['x-token'] = self.userConfig.get('token') | ||
response = requests.post(url, data=data, headers=self.headers) | ||
text = response.text | ||
data = json.loads(text) | ||
for i in data['data']['questions']: | ||
userQuestionsBank[i['id']] = {} | ||
userQuestionsBank[i['id']]['question'] = i['title'] | ||
userQuestionsBank[i['id']]['answer'] = [] | ||
userQuestionsBank[i['id']]['type'] = i['type'] | ||
userQuestionsBank[i['id']]['typeLabel'] = i['typeLabel'] | ||
for j in i['optionList']: | ||
if j['isCorrect'] == 1: | ||
userQuestionsBank[i['id']]['answer'].append(j['content']) | ||
return userQuestionsBank |
Oops, something went wrong.