怎么获取用户信息 #1128
怎么获取用户信息
#1128
-
照着doc的wbi示例签名了,还是显示412错误 import wbi
import requests
import time
# 替换为你的SESSDATA和buvid3(若需要)
SESSDATA = "[sessdata]"
buvid3 = "[buvid3]" # 可选,某些IP地址可能需要
bili_jct="[bili_jct]"
dedeuserid="[user_id]"
# 目标用户的mid
mid = 946974 # 替换为目标用户的mid
wts = round(time.time()) # 当前时间戳
signed_params = wbi.get_w_rid(mid=mid)
# 请求头,包含Cookie
headers = {
"Cookie": f"SESSDATA={SESSDATA}; buvid3={buvid3}"
}
# 请求参数
params = signed_params
print(params)
# 发送GET请求
url = "https://api.bilibili.com/x/space/wbi/acc/info"
response = requests.get(url, headers=headers, params=params)
print(response.text)
# 检查请求是否成功
if response.status_code == 200:
data = response.json()
print("请求成功!用户详细信息如下:")
print(data)
else:
print(f"请求失败,状态码:{response.status_code}") |
Beta Was this translation helpful? Give feedback.
Answered by
wuziqian211
Nov 1, 2024
Replies: 1 comment 1 reply
-
UA 应该使用浏览器的 UA,并且现在需要添加 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Lawrenceeeeeeee
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
UA 应该使用浏览器的 UA,并且现在需要添加
w_webid
参数,见 #1107