-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathJudgementApply.py
42 lines (39 loc) · 1.73 KB
/
JudgementApply.py
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
import requests as r
import json as js
checkurl='http://api.bilibili.com/x/credit/jury/requirement'
applyurl='http://api.bilibili.com/x/credit/jury/apply'
avaliability=False
def Apply(sessdata,csrf):
headers={
'cookie': 'SESSDATA={}'.format(sessdata),
'Host': 'api.bilibili.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36'
}
result=js.loads(r.get(checkurl,headers=headers).text)
blocked,cert,level,rule=result['data']['blocked'],result['data']['cert'],result['data']['level'],result['data']['rule']
if(not blocked and cert and level and rule):
global avaliability
avaliability=True
headers={
'cookie': 'bili_jct={}; SESSDATA={}'.format(csrf,sessdata),
'Host': 'api.bilibili.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36'
}
params={
'csrf': csrf
}
if(avaliability):
print('检测到未有风纪委员资格但具有申请资格,正在尝试申请……')
result=js.loads(r.post(applyurl,headers=headers,params=params).text)
print(result)
if result['code']==0:
returnmsg='申请成功'
return True,returnmsg
else:
status={
-101: '返回错误码-101,账号未登录,请检查sessdata和csrf是否有效',
-111: '返回错误码-111,csrf校验失败,请检查csrf是否有效',
25016: '返回错误码25016,当天的风纪委员资格已经发放完成'
}
returnmsg=status[result['code']]
return False,returnmsg