因为懒所有脚本没有做一键就运行,需要懂一点抓包,还有python
需要ai ,我用的是deepseek ,结果是82分。前一次用了个免费的千问7b就38分。所以建议使用deepseek,不过deepseek需要实名认证,还需要充点钱就1块就可以了,忘记了新人有没有免费送token,有就不用充还有实名了
下面就是脚本需要做的事情了
脚本需要你提供 headers cookies access_key csrf
这四个值通过抓包获取
还有ai的api_key 如果用deepseek只需要补充api_key 如果是其他api就自行修改model和api
下面是抓包
准备好抓包后,进入硬核答题,最好是选择,知识,历史,和体育。自己答第一题,找这个获取问题的url
"https://api.bilibili.com/x/senior/v1/question"的请求 这个请求就全部包含headers cookies access_key csrf四个值了
上面准备好后
手机不要退出答题界面,一定在那里。启用脚本,直到答完100道后,在手机上答题随便选一个答案,
这时候有可能直接出现答完的报告显示你多少分,有可能出现第101道题,这时候滑动手机后退页面就会出现答完的报告了
import hashlib
import time
import urllib.parse
from curl_cffi import requests //魔改的requests 库,普通的requests 应该是被b站拒绝的
def appsign(params):
appkey = '1d8b6e7d45233436'
appsec = '560c52ccd288fed045859ed18bffd973'
params.update({'appkey': appkey})
params = dict(sorted(params.items()))
query = urllib.parse.urlencode(params)
sign = hashlib.md5((query + appsec).encode()).hexdigest()
params.update({'sign': sign})
return params
headers = {
}
cookies = {
}
access_key = "..."
csrf = "..."
def get_question():
url = "https://api.bilibili.com/x/senior/v1/question"
params = {
"access_key": access_key,
"csrf": csrf,
"disable_rcmd": "0",
"mobi_app": "android",
"platform": "android",
"statistics": "{\"appId\":1,\"platform\":3,\"version\":\"8.12.0\",\"abtest\":\"\"}",
"ts": "1726121484",
"web_location": "333.790",
}
params = appsign(params)
response = requests.get(url, headers=headers, cookies=cookies, params=params, impersonate='chrome101')
if response.status_code == 200:
data = response.json().get('data')
return data
def ai_request(content):
api_key = '...'
model = 'deepseek-chat'
system_prompt = ''
url = "https://api.deepseek.com/chat/completions"
headers_ = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
"Accept": "*/*",
}
data_ = {
"model": model,
"temperature": 0,
"messages": [
{
"role": "system",
"content": system_prompt,
},
{
"role": "user",
"content": content,
}
]
}
try:
response = requests.post(url, headers=headers_, json=data_)
response.raise_for_status()
json_data = response.json()
if json_data:
return json_data['choices'][0]['message']['content']
except Exception as e:
print(str(e))
return ''
def ai_query(question_data):
answers = [i["ans_text"] for i in question_data["answers"]]
option_str = "\n".join(answers)
prompt = f'请查看下面的问题,并告诉我答案,不要返回答案本身,一定要仅返回正确答案的选项号,如果第一答案正确就返回1 \n问题是:\n{question_data["question"]}\n\n选项是:\n{option_str}'
content = ai_request(prompt)
index = -1
try:
index = int(content)
except:
if content in answers:
index = answers.index(content)
if index > 0:
index = index - 1
return {
"id": question_data['id'],
"ans_text": question_data['answers'][index]['ans_text'],
"ans_hash": question_data['answers'][index]['ans_hash'],
"question": question_data['question'],
"question_num": question_data['question_num'],
}
def submit(answer_data):
url = 'https://api.bilibili.com/x/senior/v1/answer/submit'
data = {
'access_key': access_key,
'ans_hash': answer_data['ans_hash'],
'ans_text': answer_data['ans_text'],
'csrf': csrf,
'disable_rcmd': '0',
'id': answer_data['id'],
'mobi_app': 'android',
'platform': 'android',
'statistics': '{"appId":1,"platform":3,"version":"8.12.0","abtest":""}',
'ts': '1726121484',
}
data = appsign(data)
response = requests.post(url, headers=headers, data=data, impersonate='chrome101')
if response.status_code == 200:
print(f'第{answer_data["question_num"]}题:{answer_data["question"]} 提交了答案:{answer_data["ans_text"]}\n')
if answer_data['question_num'] < 100:
return True
have_next = True
while have_next:
data = get_question()
if data:
try:
content = ai_query(data)
if content:
have_next = submit(content)
if have_next:
print('等待中......')
time.sleep(2)
except Exception as e:
print(e)
time.sleep(5)```