2465990ccc
- [d1a4f6d](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/d1a4f6dd2b4e5d57188d56671b1dfacc299ea3fd) close #1062 ~by myself~ - [ff450a6](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/ff450a65693dbdc3c9a78a05c67ddbc1a783a532) add Wbi API - [b3c3fce](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/b3c3fce1646e72985e46492224554ba8b505849a) close #707 - [fa6c9c8](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/fa6c9c8f575a617f6603935b5a77c9624dd5b9fb) new method of `buvid3` & `b_nut` from #790 - [45755b0](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/45755b01d8d9593d50658de83322dd79e7b45e21#diff-1a8d1ba142e61d01fd3b24620847ca2f2ff93f880973ea1e1d71de79d0123096R133) close #380 - [45755b0](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/45755b01d8d9593d50658de83322dd79e7b45e21#diff-1a8d1ba142e61d01fd3b24620847ca2f2ff93f880973ea1e1d71de79d0123096R542) add details in #244 - [1c5b778](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/1c5b7788f717f92a0e3f655e947db49e842f80e0) - [85e8fc5](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/85e8fc5304d94ccb7480545e38201219b71370ad) close #945
86 lines
2.3 KiB
Markdown
86 lines
2.3 KiB
Markdown
# 获取 buvid3 / buvid4 / b_nut
|
|
|
|
## 游客获取 buvid3 / buvid4
|
|
|
|
> https://api.bilibili.com/x/frontend/finger/spi
|
|
|
|
*请求方式: GET*
|
|
|
|
**JSON回复:**
|
|
|
|
根对象:
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
| ------- | ---- | -------- | -------- |
|
|
| code | num | 返回值 | 0:成功 |
|
|
| message | str | 信息 | ok: 成功 |
|
|
| data | obj | 数据本体 | |
|
|
|
|
`data`对象:
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
| ---- | ---- | ------ | ---- |
|
|
| b_3 | str | buvid3 | 需手动存放至 cookie 中 |
|
|
| b_4 | str | buvid4 | 同上 |
|
|
|
|
**示例:**
|
|
|
|
注: 建议自行生成, 不要复制本处示例的 buvid3 / buvid4.
|
|
|
|
```shell
|
|
curl -G 'https://api.bilibili.com/x/frontend/finger/spi'
|
|
```
|
|
|
|
<details>
|
|
<summary>查看响应示例:</summary>
|
|
|
|
```json
|
|
{
|
|
"code": 0,
|
|
"data": {
|
|
"b_3": "D9656DA8-9BEF-F464-5B72-C4849AFD336379044infoc",
|
|
"b_4": "F6E0FD4B-520C-1902-4F7B-E461D8D1F5AB79044-024072309-666onEZSnlHVPjoRp4kDYg=="
|
|
},
|
|
"message": "ok"
|
|
}
|
|
```
|
|
|
|
</details>
|
|
|
|
## 从响应头获取 buvid3 / b_nut
|
|
|
|
使用 `GET` 或 `HEAD` 方法请求 `https://www.bilibili.com/`, 且请求头中 `User-Agent` 字段不包含 `curl` `python` `awa` 等敏感子字符串, 且相同 `User-Agent` 字段不得短时多次请求. 在响应头中的 `Set-Cookie` 字段中, 即可找到 `buvid3` 和 `b_nut`.
|
|
|
|
若不带任何 Cookie 请求, 则 `b_nut` 为响应生成时刻的 UNIX 秒级时间戳.
|
|
若请求 Cookie 仅带有 `buvid3`, 则 `b_nut` 为 `100`.
|
|
若请求 Cookie 仅带有 `b_nut`, 则与不带任何 Cookie 的响应相同.
|
|
若请求 Cookie 仅带有 `buvid3` 和 `b_nut`, 则响应无 `Set-Cookie` 字段.
|
|
若请求 Cookie 带有其他字段, 无影响.
|
|
|
|
**示例:**
|
|
|
|
```shell
|
|
curl -I "https://www.bilibili.com/" -A "awa"
|
|
```
|
|
|
|
<details>
|
|
<summary>查看响应示例:</summary>
|
|
|
|
```http
|
|
HTTP/2 200
|
|
date: Fri, 26 Jul 2024 06:38:43 GMT
|
|
content-type: text/html; charset=utf-8
|
|
support: nantianmen
|
|
set-cookie: buvid3=805E4894-96A2-0684-6F00-C6EA1FFB911023315infoc; path=/; expires=Sat, 26 Jul 2025 06:38:43 GMT; domain=.bilibili.com
|
|
set-cookie: b_nut=1721975923; path=/; expires=Sat, 26 Jul 2025 06:38:43 GMT; domain=.bilibili.com
|
|
vary: Origin,Accept-Encoding
|
|
idc: shjd
|
|
expires: Fri, 26 Jul 2024 06:38:42 GMT
|
|
cache-control: no-cache
|
|
x-cache-webcdn: MISS from blzone01
|
|
x-cache-time: 0
|
|
x-save-date: Fri, 26 Jul 2024 06:38:43 GMT
|
|
```
|
|
|
|
</details>
|