-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
120 lines (108 loc) · 4.33 KB
/
Copy pathmain.py
File metadata and controls
120 lines (108 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import requests
import json
import time
import os
file = open("user.txt","r")
secret = file.readline().replace('\n',"")
key_session = file.readline()
file.close()
print(secret)
print(key_session)
page_headers = {
"Host": "dekt.hfut.edu.cn",
"Connection": "keep-alive",
"key_session": key_session,
"xweb_xhr": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090819)XWEB/8519",
"Content-Type": "application/json",
"Accept": "*/*",
"Accept-Language": "*",
"Sec-Fetch-Site": "cross-site",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"Referer": "https://servicewechat.com/wx1e3feaf804330562/91/page-frame.html",
"Accept-Encoding": "gzip, deflate, br"
}
question_headers = {
"Host": "dekt.hfut.edu.cn",
"Connection": "keep-alive",
"secret": secret,
"key_session": key_session,
"xweb_xhr": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090819)XWEB/8519",
"Content-Type": "application/json",
"Accept": "*/*",
"Accept-Language": "*",
"Sec-Fetch-Site": "cross-site",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"Referer": "https://servicewechat.com/wx1e3feaf804330562/91/page-frame.html",
"Accept-Encoding": "gzip, deflate, br"
}
answer_headers = {
"Host": "dekt.hfut.edu.cn",
"Connection": "keep-alive",
"key_session": key_session,
"xweb_xhr": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090819)XWEB/8519",
"Content-Type": "application/json",
"Accept": "*/*",
"Accept-Language": "*",
"Sec-Fetch-Site": "cross-site",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"Referer": "https://servicewechat.com/wx1e3feaf804330562/91/page-frame.html",
"Accept-Encoding": "gzip, deflate, br"
}
data = {
"category": "",
"columnType": "99"
}
page_num = 1
if(os.path.exists("last.txt")):
file = open("last.txt","r")
tmp = file.readline().replace('\n','')
page_num = int(tmp)
while page_num <= 100 :
print("page:"+str(page_num)+"\n")
url = f"https://dekt.hfut.edu.cn/scReports/api/wx/netlearning/page/{page_num}/10"
response = requests.post(url, headers=page_headers, data=json.dumps(data))
#print(response.content)
page_data = response.json()
page_num += 1
#print(page_data)
for question in page_data["data"]["list"]:
#print(question['title']+":")
if (question["correct"] == "已完成"):
continue
#print("reach A")
question_id = question["id"]
url = f"https://dekt.hfut.edu.cn/scReports/api/wx/netlearning/questions/{question_id}"
time.sleep(1)
response = requests.get(url, headers=question_headers)
question_detail = response.json()
if(("data" not in question_detail) or ("questions" not in question_detail["data"]) or ()):
continue
#print("reach B")
if(question_detail["data"]["todayReach"]):
file = open("last.txt","w")
file.write(str(page_num))
exit() #达到每日上限
for question in question_detail["data"]["questions"]:
#print("reach C")
if(question["queType"]): #只做单选题
continue
#print("reach D")
sbid = question["id"]
for option in question["optionList"]:
option_id = option["id"]
url = f"https://dekt.hfut.edu.cn/scReports/api/wx/netlearning/answer/{sbid}"
time.sleep(1)
data = [option_id]
response = requests.post(url, headers=answer_headers, json=data)
recv_data = response.json()
if recv_data["data"]["desc"] == "恭喜,获得积分":
print("+1\n")
break
file = open("last.txt","w")
file.write(page_num)