Open TDK1969 opened 1 year ago
webgl_str
我的,这下看懂了
def get_user_space(user_id: int): r1 = httpx.get( "https://space.bilibili.com/1133258171/dynamic", headers={ "Host": "space.bilibili.com", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36", }, ) print(r1.cookies) url = "https://api.bilibili.com/x/internal/gaia-gateway/ExClimbWuzhi" payload ='' # payload 是浏览器指纹,自己去抓一下用,浏览器无痕模式进入某个动态页面即可抓到 headers = { "authority": "api.bilibili.com", "accept": "*/*", "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", "content-type": "application/json;charset=UTF-8", "dnt": "1", "origin": "https://space.bilibili.com", "referer": "https://space.bilibili.com/1133258171/dynamic", "sec-ch-ua": '"Not.A/Brand";v="8", "Chromium";v="114", "Microsoft Edge";v="114"', "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": '"Windows"', "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-site", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.58", } response = httpx.post(url, headers=headers, data=payload, cookies=r1.cookies) print(response.json) params = { "host_mid": user_id, } r = httpx.get( "https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space", params=params, headers={ "Host": "api.bilibili.com", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36", }, cookies=r1.cookies, ) res = r.json() print(res) return res get_user_space(1133258171)
payload参数注意需要自己抓一下包,应该是浏览器指纹,我就不放出来了。
浏览器测试的话需要打开无痕模式,第一次打开页面会带着从
/dynamic
获取的cookie
去请求/x/internal/gaia-gateway/ExClimbWuzhi
接口,但注意这个接口会被广告屏蔽软件如ublock屏蔽,导出跳出验证码。如果你尝试在无痕模式清除
cookie
后请求页面,会触发验证码
发现 UA 里面 Chrome/92
版本就抓不到,非常神奇
OK. your email has been received.
第二步 POST 的时候返回{'code': 130212, 'message': '130212', 'ttl': 1, 'data': None}
,不知道啥情况
/x/polymer/web-dynamic/v1/feed/space
接口用于获取指定用户的动态列表 以前该接口使用正常,自2023.5.24下午5点20左右开始,在不带cookie下访问该接口会返回错误-352,如下: