import{_ as e,c as a,a as n,o as t}from"./app-CDdN0tOz.js";const l={};function o(i,s){return t(),a("div",null,s[0]||(s[0]=[n(`<h1 id="获取-buvid3-buvid4-b-nut" tabindex="-1"><a class="header-anchor" href="#获取-buvid3-buvid4-b-nut"><span>获取 buvid3 / buvid4 / b_nut</span></a></h1><h2 id="仅获取-buvid3" tabindex="-1"><a class="header-anchor" href="#仅获取-buvid3"><span>仅获取 buvid3</span></a></h2><blockquote><p>https://api.bilibili.com/x/web-frontend/getbuvid</p></blockquote><p><em>请求方式: GET</em></p><p><strong>JSON回复:</strong></p><p>根对象:</p><table><thead><tr><th>字段</th><th>类型</th><th>内容</th><th>备注</th></tr></thead><tbody><tr><td>code</td><td>num</td><td>返回值</td><td>0：成功</td></tr><tr><td>data</td><td>obj</td><td>数据本体</td><td></td></tr></tbody></table><p><code>data</code>对象:</p><table><thead><tr><th>字段</th><th>类型</th><th>内容</th><th>备注</th></tr></thead><tbody><tr><td>buvid</td><td>str</td><td>buvid3</td><td>需手动存放至 cookie 中</td></tr></tbody></table><p><strong>示例:</strong></p><p>注: 不要复制</p><div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-shell"><span class="line"><span style="color:#DCDCAA;">curl</span><span style="color:#569CD6;"> -G</span><span style="color:#CE9178;"> &#39;https://api.bilibili.com/x/web-frontend/getbuvid&#39;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><details><summary>查看响应示例:</summary><div class="language-json line-numbers-mode" data-highlighter="shiki" data-ext="json" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-json"><span class="line"><span style="color:#D4D4D4;">{</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;code&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;data&quot;</span><span style="color:#D4D4D4;">: {</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;buvid&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;54E5EFC1-3C8F-F690-2261-439E4F6A20A979439infoc&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">  }</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h2 id="接口获取-buvid3-buvid4" tabindex="-1"><a class="header-anchor" href="#接口获取-buvid3-buvid4"><span>接口获取 buvid3 / buvid4</span></a></h2><blockquote><p>https://api.bilibili.com/x/frontend/finger/spi</p></blockquote><p><em>请求方式: GET</em></p><p><strong>JSON回复:</strong></p><p>根对象:</p><table><thead><tr><th>字段</th><th>类型</th><th>内容</th><th>备注</th></tr></thead><tbody><tr><td>code</td><td>num</td><td>返回值</td><td>0：成功</td></tr><tr><td>message</td><td>str</td><td>信息</td><td>ok: 成功</td></tr><tr><td>data</td><td>obj</td><td>数据本体</td><td></td></tr></tbody></table><p><code>data</code>对象:</p><table><thead><tr><th>字段</th><th>类型</th><th>内容</th><th>备注</th></tr></thead><tbody><tr><td>b_3</td><td>str</td><td>buvid3</td><td>需手动存放至 cookie 中</td></tr><tr><td>b_4</td><td>str</td><td>buvid4</td><td>同上</td></tr></tbody></table><p><strong>示例:</strong></p><p>注: 建议自行生成, 不要复制本处示例的 buvid3 / buvid4.</p><div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-shell"><span class="line"><span style="color:#DCDCAA;">curl</span><span style="color:#569CD6;"> -G</span><span style="color:#CE9178;"> &#39;https://api.bilibili.com/x/frontend/finger/spi&#39;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><details><summary>查看响应示例:</summary><div class="language-json line-numbers-mode" data-highlighter="shiki" data-ext="json" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-json"><span class="line"><span style="color:#D4D4D4;">{</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;code&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;data&quot;</span><span style="color:#D4D4D4;">: {</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;b_3&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;D9656DA8-9BEF-F464-5B72-C4849AFD336379044infoc&quot;</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#9CDCFE;">    &quot;b_4&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;F6E0FD4B-520C-1902-4F7B-E461D8D1F5AB79044-024072309-666onEZSnlHVPjoRp4kDYg==&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">  },</span></span>
<span class="line"><span style="color:#9CDCFE;">  &quot;message&quot;</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;ok&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h2 id="从响应头获取-buvid3-b-nut" tabindex="-1"><a class="header-anchor" href="#从响应头获取-buvid3-b-nut"><span>从响应头获取 buvid3 / b_nut</span></a></h2><p>使用 <code>GET</code> 或 <code>HEAD</code> 方法请求 <code>https://www.bilibili.com/</code>, 且请求头中 <code>User-Agent</code> 字段不包含 <code>curl</code> <code>python</code> <code>awa</code> 等敏感子字符串, 且相同 <code>User-Agent</code> 字段不得短时多次请求. 在响应头中的 <code>Set-Cookie</code> 字段中, 即可找到 <code>buvid3</code> 和 <code>b_nut</code>.</p><p>若不带任何 Cookie 请求, 则 <code>b_nut</code> 为响应生成时刻的 UNIX 秒级时间戳. 若请求 Cookie 仅带有 <code>buvid3</code>, 则 <code>b_nut</code> 为 <code>100</code>. 若请求 Cookie 仅带有 <code>b_nut</code>, 则与不带任何 Cookie 的响应相同. 若请求 Cookie 仅带有 <code>buvid3</code> 和 <code>b_nut</code>, 则响应无 <code>Set-Cookie</code> 字段. 若请求 Cookie 带有其他字段, 无影响.</p><p><strong>示例:</strong></p><div class="language-shell line-numbers-mode" data-highlighter="shiki" data-ext="shell" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-shell"><span class="line"><span style="color:#DCDCAA;">curl</span><span style="color:#569CD6;"> -I</span><span style="color:#CE9178;"> &quot;https://www.bilibili.com/&quot;</span><span style="color:#569CD6;"> -A</span><span style="color:#CE9178;"> &quot;awa&quot;</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><details><summary>查看响应示例:</summary><div class="language-http line-numbers-mode" data-highlighter="shiki" data-ext="http" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-http"><span class="line"><span style="color:#D4D4D4;">HTTP/2 </span><span style="color:#B5CEA8;">200</span><span style="color:#D4D4D4;"> </span></span>
<span class="line"><span style="color:#569CD6;">date:</span><span style="color:#CE9178;"> Fri, 26 Jul 2024 06:38:43 GMT</span></span>
<span class="line"><span style="color:#569CD6;">content-type:</span><span style="color:#CE9178;"> text/html; charset=utf-8</span></span>
<span class="line"><span style="color:#569CD6;">support:</span><span style="color:#CE9178;"> nantianmen</span></span>
<span class="line"><span style="color:#569CD6;">set-cookie:</span><span style="color:#CE9178;"> buvid3=805E4894-96A2-0684-6F00-C6EA1FFB911023315infoc; path=/; expires=Sat, 26 Jul 2025 06:38:43 GMT; domain=.bilibili.com</span></span>
<span class="line"><span style="color:#569CD6;">set-cookie:</span><span style="color:#CE9178;"> b_nut=1721975923; path=/; expires=Sat, 26 Jul 2025 06:38:43 GMT; domain=.bilibili.com</span></span>
<span class="line"><span style="color:#569CD6;">vary:</span><span style="color:#CE9178;"> Origin,Accept-Encoding</span></span>
<span class="line"><span style="color:#569CD6;">idc:</span><span style="color:#CE9178;"> shjd</span></span>
<span class="line"><span style="color:#569CD6;">expires:</span><span style="color:#CE9178;"> Fri, 26 Jul 2024 06:38:42 GMT</span></span>
<span class="line"><span style="color:#569CD6;">cache-control:</span><span style="color:#CE9178;"> no-cache</span></span>
<span class="line"><span style="color:#569CD6;">x-cache-webcdn:</span><span style="color:#CE9178;"> MISS from blzone01</span></span>
<span class="line"><span style="color:#569CD6;">x-cache-time:</span><span style="color:#CE9178;"> 0</span></span>
<span class="line"><span style="color:#569CD6;">x-save-date:</span><span style="color:#CE9178;"> Fri, 26 Jul 2024 06:38:43 GMT</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details>`,31)]))}const c=e(l,[["render",o]]),r=JSON.parse('{"path":"/docs/misc/buvid3_4.html","title":"获取 buvid3 / buvid4 / b_nut","lang":"zh-CN","frontmatter":{},"git":{"updatedTime":1726759053000,"contributors":[{"name":"SessionHu","username":"SessionHu","email":"102411014+SessionHu@users.noreply.github.com","commits":4,"url":"https://github.com/SessionHu"},{"name":"SocialSisterYi","username":"SocialSisterYi","email":"45892418+SocialSisterYi@users.noreply.github.com","commits":1,"url":"https://github.com/SocialSisterYi"}],"changelog":[{"hash":"1e24c6b1889160c4c35c01416aa4239501accf5f","time":1726759053000,"email":"102411014+SessionHu@users.noreply.github.com","author":"Session小胡","message":"调整部分接口描述与错误修复 (#1088)","coAuthors":[{"name":"社会易姐QwQ","email":"45892418+SocialSisterYi@users.noreply.github.com"}]},{"hash":"60a0c5d1a2f44fe61335da04571305fa7727a968","time":1724238159000,"email":"102411014+SessionHu@users.noreply.github.com","author":"Session小胡","message":"feat: 各种接口补充与错误修正 (#1066)"},{"hash":"2465990ccc5aea35ad6d0b17dc7c2f36bc5e45c0","time":1722059352000,"email":"102411014+SessionHu@users.noreply.github.com","author":"Session小胡","message":"feat: 更新web端视频操作播放合集相关接口 (#1064)"},{"hash":"18c1efbc102ae6b44c8f5314c90e5e64f0d926cd","time":1721909032000,"email":"102411014+SessionHu@users.noreply.github.com","author":"Session小胡","message":"feat: bili_ticket 算法 Java 实现 及 信息补充 及 错误修正 (#1061)"}]},"filePathRelative":"docs/misc/buvid3_4.md"}');export{c as comp,r as data};
