bilibili-api-python


Namebilibili-api-python JSON
Version 17.4.0 PyPI version JSON
download
home_pageNone
SummaryThe fork of module bilibili-api. 哔哩哔哩的各种 API 调用便捷整合(视频、动态、直播等),另外附加一些常用的功能。
upload_time2025-10-08 05:26:35
maintainerMoyuScript, Nemo2011
docs_urlNone
authorNone
requires_python>=3.9
licenseGPL-3.0-or-later
keywords bilibili api spider
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![bilibili-api logo](https://raw.githubusercontent.com/Nemo2011/bilibili-api/main/design/logo.png)

<div align="center">

# bilibili-api

[![API 数量](https://img.shields.io/badge/API%20数量-400+-blue)][api.json]
[![LICENSE](https://img.shields.io/badge/LICENSE-GPLv3+-red)][LICENSE]
[![Python](https://img.shields.io/badge/python-3.9+-blue)](https://www.python.org)
[![Stable Version](https://img.shields.io/pypi/v/bilibili-api-python?label=stable)][pypi]
[![Pre-release Version](https://img.shields.io/github/v/release/Nemo2011/bilibili-api?label=pre-release&include_prereleases&sort=semver)][pypi-dev]
[![STARS](https://img.shields.io/github/stars/nemo2011/bilibili-api?color=yellow&label=Github%20Stars)][stargazers]
[![Testing](https://github.com/Nemo2011/bilibili-api/actions/workflows/testing.yml/badge.svg?branch=dev)](https://github.com/Nemo2011/bilibili-api/actions/workflows/testing.yml)

**:warning: 接口可能改动,请及时更新最新版 [![Stable Version](https://img.shields.io/pypi/v/bilibili-api-python?label=stable)][pypi]**

</div>

**注意事项:使用此模块时请仅用于学习和测试,禁止用于非法用途及其他恶劣的社区行为如:恶意刷屏、辱骂黄暴、各种形式的滥用等,违规此模块许可证 `GNU General Public License Version 3` 及此条注意事项而产生的任何后果自负,模块的所有贡献者不负任何责任。**

开发文档: [bilibili_api 开发文档][docs] ([GitHub][docs-github])

原仓库地址:[https://github.com/MoyuScript/bilibili-api](https://github.com/MoyuScript/bilibili-api) (*现已被删除)

Github 仓库:[https://github.com/nemo2011/bilibili-api](https://github.com/nemo2011/bilibili-api)

> 模块最早由 @MoyuScript 于 2020 年创建,于 2022 年宣布停止维护。本仓库是原仓库 fork,遵循 `GNU General Public License Version 3`。在此感谢早期的众多模块贡献者与 @MoyuScript 对新仓库的支持。
> 见 `MoyuScript/bilibili-api` 的 [第一条 commit (2020.01.27)](https://github.com/Nemo2011/bilibili-api/commit/8dc3f9a05fa28ed9b060cafa6d5c23131a28a113)与 [最后一条 commit (2022.01.17)](https://github.com/Nemo2011/bilibili-api/commit/dc518016c7649be2a135ccb8badb091712754a3d)。

# 简介

这是一个用 Python 写的调用 [Bilibili](https://www.bilibili.com) 各种 API 的库,
范围涵盖视频、音频、直播、动态、专栏、用户、番剧等[[1]](#脚注)。

## 特色

- 范围涵盖广,基本覆盖常用的爬虫,操作。
- 可使用代理,绕过 b 站风控策略。
- 全面支持 BV 号(bvid),同时也兼容 AV 号(aid)。
- 调用简便,函数命名易懂,代码注释详细。
- 不仅仅是官方提供的 API!还附加:AV 号与 BV 号互转[[2]](#脚注)、连接直播弹幕 Websocket 服务器、视频弹幕反查、下载弹幕、字幕文件[[3]](#脚注)、专栏内容爬取、cookies 刷新等[[4]](#脚注)。
- 支持采用各种手段避免触发反爬虫风控[[5]](#脚注)。
- **全部是异步操作**。
- 默认支持 `aiohttp` / `httpx` / `curl_cffi`。

# 快速上手

首先使用以下指令安装本模块:

```
# 主版本
$ pip3 install bilibili-api-python

# 开发版本
$ pip3 install bilibili-api-dev

# 最新修改会在 dev 分支
$ pip3 install git+https://github.com/Nemo2011/bilibili-api.git@dev
```

然后需要**自行安装**一个支持异步的第三方请求库,如 `aiohttp` / `httpx` / `curl_cffi`。

```
# aiohttp
$ pip3 install aiohttp

# httpx
$ pip3 install httpx

# curl_cffi
$ pip3 install "curl_cffi"
```

接下来我们来获取视频的播放量等信息:

```python
import asyncio
from bilibili_api import video


async def main() -> None:
    # 实例化 Video 类
    v = video.Video(bvid="BV1uv411q7Mv")
    # 获取信息
    info = await v.get_info()
    # 打印信息
    print(info)


if __name__ == "__main__":
    asyncio.run(main())

```

输出(已格式化,已省略部分):

```json
{
    "bvid": "BV1uv411q7Mv",
    "aid": 243922477,
    "videos": 1,
    "tid": 17,
    "tname": "单机游戏",
    "copyright": 1,
    "pic": "http://i2.hdslb.com/bfs/archive/82e52df9d0221836c260c82f2890e3761a46716b.jpg",
    "title": "爆肝98小时!在 MC 中还原糖调小镇",
    "pubdate": 1595203214,
    "ctime": 1595168654,
    ...and more
}
```

如何给这个视频点赞?我们需要登录自己的账号。

这里设计是传入一个 Credential 类,获取所需的信息参照:[获取 Credential 类所需信息][get-credential]

下面的代码将会给视频点赞

```python
import asyncio
from bilibili_api import video, Credential

async def main() -> None:
    # 实例化 Credential 类
    credential = Credential(sessdata=SESSDATA, bili_jct=BILI_JCT, buvid3=BUVID3)
    # 实例化 Video 类
    v = video.Video(bvid="BVxxxxxxxx", credential=credential)
    info = await v.get_info()
    print(info)
    # 给视频点赞
    await v.like(True)

if __name__ == '__main__':
    asyncio.run(main())
```

如果没有报错,就代表调用 API 成功,你可以到视频页面确认是不是调用成功了。

> **Warning** 注意,请不要泄露这两个值给他人,否则你的账号将可能遭受盗号的风险!

# 异步迁移

由于从 v5 版本开始,基本全部改为异步,如果你不会异步,可以参考 [asyncio](https://docs.python.org/zh-cn/3/library/asyncio.html)

异步可以进行并发请求,性能更高,不过如果请求过快仍然会导致被屏蔽。

总的来说,异步比同步更有优势,所以不会的话可以去学一下,会发现新天地(误

如果你仍然想继续使用同步代码,请参考 [同步执行异步代码](https://nemo2011.github.io/bilibili-api/#/sync-executor)

# 模块使用的请求库

模块在允许的条件下,按照 `curl_cffi` `aiohttp` `httpx` 的优先级选择第三方请求库。

如果想要指定请求库,可以利用 `select_client` 进行切换。

``` python
from bilibili_api import select_client

select_client("curl_cffi") # 选择 curl_cffi,支持伪装浏览器的 TLS / JA3 / Fingerprint
select_client("aiohttp") # 选择 aiohttp
select_client("httpx") # 选择 httpx,不支持 WebSocket
```

curl_cffi 支持伪装浏览器的 TLS / JA3 / Fingerprint,但需要手动设置。

``` python
from bilibili_api import request_settings

request_settings.set("impersonate", "chrome131") # 第二参数数值参考 curl_cffi 文档
# https://curl-cffi.readthedocs.io/en/latest/impersonate.html
```

# FA♂Q

**Q: 关于 API 调用的正确姿势是什么?**

A: 所有 API 调用,请尽量使用 **指名方式** 传参,
因为 API 较多,可能不同函数的传参顺序不一样,例子:

```python
# 推荐
video.get_info(bvid="BV1uv411q7Mv")

# 当然也可以这样
kwargs = {
    "bvid": "BV1uv411q7Mv"
}
video.get_info(**kwargs)

# 不推荐
video.get_info("BV1uv411q7Mv")
```

**Q: 为什么会提示 412 Precondition Failed ?**

A: 你的请求速度太快了。造成请求速度过快的原因可能是你写了高并发的代码。

这种情况下,你的 IP 会暂时被封禁而无法使用,你可以设置代理绕过。

```python
from bilibili_api import request_settings

request_settings.set_proxy("http://your-proxy.com") # 里头填写你的代理地址

request_settings.set_proxy("http://username:password@your-proxy.com") # 如果需要用户名、密码
```

**Q: 我想在项目中使用这个模块,但是我的项目使用其他请求库进行网络请求(如 `pycurl`),想要模块也同时使用它(们),可以吗?**

A: 可以,但是你可能要自己动手实现模块和具体请求库的适配。详见 [自定义请求库](https://nemo2011.github.io/bilibili-api/#/request_client)

**Q: 怎么没有我想要的功能?**

A: 你可以发 Issue 来提交你的需求,但是,最好的办法是自己写(懒)

<span id="contribute">**Q: 我有一个大胆的想法,如何给代码库贡献?**</span>

A: 请先 clone 本仓库一份,然后从 main 分支新建一个分支,在该分支上工作。
如果你觉得已经可以了,请向项目仓库的 develop 分支发起 Pull request。
如果你不明白这些操作的话,可以百度。完整指南:[CONTRIBUTING.md](https://github.com/nemo2011/bilibili-api/blob/main/.github/CONTRIBUTING.md)

**Q: 稳定性怎么样?**

A: 由于该模块比较特殊,是爬虫模块,如果 b 站的接口变更,可能会马上失效。因此请始终保证是最新版本。如果发现问题可以提 [Issues][issues-new]。

# 脚注

- \[1\] 这里只列出一部分,请以实际 API 为准。
- \[2\] 代码来源:<https://www.zhihu.com/question/381784377/answer/1099438784> (WTFPL)
- \[3\] 部分代码来源:<https://github.com/m13253/danmaku2ass> (GPLv3) <https://github.com/ewwink/python-srt2ass>
- \[4\] 思路来源:<https://socialsisteryi.github.io/bilibili-API-collect/docs/login/cookie_refresh.html> (CC-BY-NC 4.0)
- \[5\] 大量思路来源 <https://github.com/SocialSisterYi/bilibili-API-collect> 中相关讨论。

[docs]: https://nemo2011.github.io/bilibili-api
[docs-github]: https://github.com/nemo2011/bilibili-api/tree/main/docs
[api.json]: https://github.com/nemo2011/bilibili-api/tree/main/bilibili_api/data/api/
[license]: https://github.com/nemo2011/bilibili-api/tree/main/LICENSE
[stargazers]: https://github.com/nemo2011/bilibili-api/stargazers
[issues-new]: https://github.com/Nemo2011/bilibili-api/issues/new/choose
[get-credential]: https://nemo2011.github.io/bilibili-api/#/get-credential
[pypi]: https://pypi.org/project/bilibili-api-python
[pypi-dev]: https://pypi.org/project/bilibili-api-dev

# Star History

[![Star History Chart](https://api.star-history.com/svg?repos=Nemo2011/bilibili-api&type=Date)](https://star-history.com/#Nemo2011/bilibili-api&Date)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "bilibili-api-python",
    "maintainer": "MoyuScript, Nemo2011",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "bilibili, api, spider",
    "author": null,
    "author_email": "Nemo2011 <yimoxia@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/54/b3/ca6c715311d80604ad37437bc1422c4bec7159db6ab49a311478f38e45ed/bilibili_api_python-17.4.0.tar.gz",
    "platform": null,
    "description": "![bilibili-api logo](https://raw.githubusercontent.com/Nemo2011/bilibili-api/main/design/logo.png)\n\n<div align=\"center\">\n\n# bilibili-api\n\n[![API \u6570\u91cf](https://img.shields.io/badge/API%20\u6570\u91cf-400+-blue)][api.json]\n[![LICENSE](https://img.shields.io/badge/LICENSE-GPLv3+-red)][LICENSE]\n[![Python](https://img.shields.io/badge/python-3.9+-blue)](https://www.python.org)\n[![Stable Version](https://img.shields.io/pypi/v/bilibili-api-python?label=stable)][pypi]\n[![Pre-release Version](https://img.shields.io/github/v/release/Nemo2011/bilibili-api?label=pre-release&include_prereleases&sort=semver)][pypi-dev]\n[![STARS](https://img.shields.io/github/stars/nemo2011/bilibili-api?color=yellow&label=Github%20Stars)][stargazers]\n[![Testing](https://github.com/Nemo2011/bilibili-api/actions/workflows/testing.yml/badge.svg?branch=dev)](https://github.com/Nemo2011/bilibili-api/actions/workflows/testing.yml)\n\n**:warning: \u63a5\u53e3\u53ef\u80fd\u6539\u52a8\uff0c\u8bf7\u53ca\u65f6\u66f4\u65b0\u6700\u65b0\u7248 [![Stable Version](https://img.shields.io/pypi/v/bilibili-api-python?label=stable)][pypi]**\n\n</div>\n\n**\u6ce8\u610f\u4e8b\u9879\uff1a\u4f7f\u7528\u6b64\u6a21\u5757\u65f6\u8bf7\u4ec5\u7528\u4e8e\u5b66\u4e60\u548c\u6d4b\u8bd5\uff0c\u7981\u6b62\u7528\u4e8e\u975e\u6cd5\u7528\u9014\u53ca\u5176\u4ed6\u6076\u52a3\u7684\u793e\u533a\u884c\u4e3a\u5982\uff1a\u6076\u610f\u5237\u5c4f\u3001\u8fb1\u9a82\u9ec4\u66b4\u3001\u5404\u79cd\u5f62\u5f0f\u7684\u6ee5\u7528\u7b49\uff0c\u8fdd\u89c4\u6b64\u6a21\u5757\u8bb8\u53ef\u8bc1 `GNU General Public License Version 3` \u53ca\u6b64\u6761\u6ce8\u610f\u4e8b\u9879\u800c\u4ea7\u751f\u7684\u4efb\u4f55\u540e\u679c\u81ea\u8d1f\uff0c\u6a21\u5757\u7684\u6240\u6709\u8d21\u732e\u8005\u4e0d\u8d1f\u4efb\u4f55\u8d23\u4efb\u3002**\n\n\u5f00\u53d1\u6587\u6863: [bilibili_api \u5f00\u53d1\u6587\u6863][docs] ([GitHub][docs-github])\n\n\u539f\u4ed3\u5e93\u5730\u5740\uff1a[https://github.com/MoyuScript/bilibili-api](https://github.com/MoyuScript/bilibili-api) (*\u73b0\u5df2\u88ab\u5220\u9664)\n\nGithub \u4ed3\u5e93\uff1a[https://github.com/nemo2011/bilibili-api](https://github.com/nemo2011/bilibili-api)\n\n> \u6a21\u5757\u6700\u65e9\u7531 @MoyuScript \u4e8e 2020 \u5e74\u521b\u5efa\uff0c\u4e8e 2022 \u5e74\u5ba3\u5e03\u505c\u6b62\u7ef4\u62a4\u3002\u672c\u4ed3\u5e93\u662f\u539f\u4ed3\u5e93 fork\uff0c\u9075\u5faa `GNU General Public License Version 3`\u3002\u5728\u6b64\u611f\u8c22\u65e9\u671f\u7684\u4f17\u591a\u6a21\u5757\u8d21\u732e\u8005\u4e0e @MoyuScript \u5bf9\u65b0\u4ed3\u5e93\u7684\u652f\u6301\u3002\n> \u89c1 `MoyuScript/bilibili-api` \u7684 [\u7b2c\u4e00\u6761 commit (2020.01.27)](https://github.com/Nemo2011/bilibili-api/commit/8dc3f9a05fa28ed9b060cafa6d5c23131a28a113)\u4e0e [\u6700\u540e\u4e00\u6761 commit (2022.01.17)](https://github.com/Nemo2011/bilibili-api/commit/dc518016c7649be2a135ccb8badb091712754a3d)\u3002\n\n# \u7b80\u4ecb\n\n\u8fd9\u662f\u4e00\u4e2a\u7528 Python \u5199\u7684\u8c03\u7528 [Bilibili](https://www.bilibili.com) \u5404\u79cd API \u7684\u5e93\uff0c\n\u8303\u56f4\u6db5\u76d6\u89c6\u9891\u3001\u97f3\u9891\u3001\u76f4\u64ad\u3001\u52a8\u6001\u3001\u4e13\u680f\u3001\u7528\u6237\u3001\u756a\u5267\u7b49[[1]](#\u811a\u6ce8)\u3002\n\n## \u7279\u8272\n\n- \u8303\u56f4\u6db5\u76d6\u5e7f\uff0c\u57fa\u672c\u8986\u76d6\u5e38\u7528\u7684\u722c\u866b\uff0c\u64cd\u4f5c\u3002\n- \u53ef\u4f7f\u7528\u4ee3\u7406\uff0c\u7ed5\u8fc7 b \u7ad9\u98ce\u63a7\u7b56\u7565\u3002\n- \u5168\u9762\u652f\u6301 BV \u53f7\uff08bvid\uff09\uff0c\u540c\u65f6\u4e5f\u517c\u5bb9 AV \u53f7\uff08aid\uff09\u3002\n- \u8c03\u7528\u7b80\u4fbf\uff0c\u51fd\u6570\u547d\u540d\u6613\u61c2\uff0c\u4ee3\u7801\u6ce8\u91ca\u8be6\u7ec6\u3002\n- \u4e0d\u4ec5\u4ec5\u662f\u5b98\u65b9\u63d0\u4f9b\u7684 API\uff01\u8fd8\u9644\u52a0\uff1aAV \u53f7\u4e0e BV \u53f7\u4e92\u8f6c[[2]](#\u811a\u6ce8)\u3001\u8fde\u63a5\u76f4\u64ad\u5f39\u5e55 Websocket \u670d\u52a1\u5668\u3001\u89c6\u9891\u5f39\u5e55\u53cd\u67e5\u3001\u4e0b\u8f7d\u5f39\u5e55\u3001\u5b57\u5e55\u6587\u4ef6[[3]](#\u811a\u6ce8)\u3001\u4e13\u680f\u5185\u5bb9\u722c\u53d6\u3001cookies \u5237\u65b0\u7b49[[4]](#\u811a\u6ce8)\u3002\n- \u652f\u6301\u91c7\u7528\u5404\u79cd\u624b\u6bb5\u907f\u514d\u89e6\u53d1\u53cd\u722c\u866b\u98ce\u63a7[[5]](#\u811a\u6ce8)\u3002\n- **\u5168\u90e8\u662f\u5f02\u6b65\u64cd\u4f5c**\u3002\n- \u9ed8\u8ba4\u652f\u6301 `aiohttp` / `httpx` / `curl_cffi`\u3002\n\n# \u5feb\u901f\u4e0a\u624b\n\n\u9996\u5148\u4f7f\u7528\u4ee5\u4e0b\u6307\u4ee4\u5b89\u88c5\u672c\u6a21\u5757\uff1a\n\n```\n# \u4e3b\u7248\u672c\n$ pip3 install bilibili-api-python\n\n# \u5f00\u53d1\u7248\u672c\n$ pip3 install bilibili-api-dev\n\n# \u6700\u65b0\u4fee\u6539\u4f1a\u5728 dev \u5206\u652f\n$ pip3 install git+https://github.com/Nemo2011/bilibili-api.git@dev\n```\n\n\u7136\u540e\u9700\u8981**\u81ea\u884c\u5b89\u88c5**\u4e00\u4e2a\u652f\u6301\u5f02\u6b65\u7684\u7b2c\u4e09\u65b9\u8bf7\u6c42\u5e93\uff0c\u5982 `aiohttp` / `httpx` / `curl_cffi`\u3002\n\n```\n# aiohttp\n$ pip3 install aiohttp\n\n# httpx\n$ pip3 install httpx\n\n# curl_cffi\n$ pip3 install \"curl_cffi\"\n```\n\n\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u83b7\u53d6\u89c6\u9891\u7684\u64ad\u653e\u91cf\u7b49\u4fe1\u606f\uff1a\n\n```python\nimport asyncio\nfrom bilibili_api import video\n\n\nasync def main() -> None:\n    # \u5b9e\u4f8b\u5316 Video \u7c7b\n    v = video.Video(bvid=\"BV1uv411q7Mv\")\n    # \u83b7\u53d6\u4fe1\u606f\n    info = await v.get_info()\n    # \u6253\u5370\u4fe1\u606f\n    print(info)\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n\n```\n\n\u8f93\u51fa\uff08\u5df2\u683c\u5f0f\u5316\uff0c\u5df2\u7701\u7565\u90e8\u5206\uff09\uff1a\n\n```json\n{\n    \"bvid\": \"BV1uv411q7Mv\",\n    \"aid\": 243922477,\n    \"videos\": 1,\n    \"tid\": 17,\n    \"tname\": \"\u5355\u673a\u6e38\u620f\",\n    \"copyright\": 1,\n    \"pic\": \"http://i2.hdslb.com/bfs/archive/82e52df9d0221836c260c82f2890e3761a46716b.jpg\",\n    \"title\": \"\u7206\u809d\uff19\uff18\u5c0f\u65f6\uff01\u5728 MC \u4e2d\u8fd8\u539f\u7cd6\u8c03\u5c0f\u9547\",\n    \"pubdate\": 1595203214,\n    \"ctime\": 1595168654,\n    ...and more\n}\n```\n\n\u5982\u4f55\u7ed9\u8fd9\u4e2a\u89c6\u9891\u70b9\u8d5e\uff1f\u6211\u4eec\u9700\u8981\u767b\u5f55\u81ea\u5df1\u7684\u8d26\u53f7\u3002\n\n\u8fd9\u91cc\u8bbe\u8ba1\u662f\u4f20\u5165\u4e00\u4e2a Credential \u7c7b\uff0c\u83b7\u53d6\u6240\u9700\u7684\u4fe1\u606f\u53c2\u7167\uff1a[\u83b7\u53d6 Credential \u7c7b\u6240\u9700\u4fe1\u606f][get-credential]\n\n\u4e0b\u9762\u7684\u4ee3\u7801\u5c06\u4f1a\u7ed9\u89c6\u9891\u70b9\u8d5e\n\n```python\nimport asyncio\nfrom bilibili_api import video, Credential\n\nasync def main() -> None:\n    # \u5b9e\u4f8b\u5316 Credential \u7c7b\n    credential = Credential(sessdata=SESSDATA, bili_jct=BILI_JCT, buvid3=BUVID3)\n    # \u5b9e\u4f8b\u5316 Video \u7c7b\n    v = video.Video(bvid=\"BVxxxxxxxx\", credential=credential)\n    info = await v.get_info()\n    print(info)\n    # \u7ed9\u89c6\u9891\u70b9\u8d5e\n    await v.like(True)\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```\n\n\u5982\u679c\u6ca1\u6709\u62a5\u9519\uff0c\u5c31\u4ee3\u8868\u8c03\u7528 API \u6210\u529f\uff0c\u4f60\u53ef\u4ee5\u5230\u89c6\u9891\u9875\u9762\u786e\u8ba4\u662f\u4e0d\u662f\u8c03\u7528\u6210\u529f\u4e86\u3002\n\n> **Warning** \u6ce8\u610f\uff0c\u8bf7\u4e0d\u8981\u6cc4\u9732\u8fd9\u4e24\u4e2a\u503c\u7ed9\u4ed6\u4eba\uff0c\u5426\u5219\u4f60\u7684\u8d26\u53f7\u5c06\u53ef\u80fd\u906d\u53d7\u76d7\u53f7\u7684\u98ce\u9669\uff01\n\n# \u5f02\u6b65\u8fc1\u79fb\n\n\u7531\u4e8e\u4ece v5 \u7248\u672c\u5f00\u59cb\uff0c\u57fa\u672c\u5168\u90e8\u6539\u4e3a\u5f02\u6b65\uff0c\u5982\u679c\u4f60\u4e0d\u4f1a\u5f02\u6b65\uff0c\u53ef\u4ee5\u53c2\u8003 [asyncio](https://docs.python.org/zh-cn/3/library/asyncio.html)\n\n\u5f02\u6b65\u53ef\u4ee5\u8fdb\u884c\u5e76\u53d1\u8bf7\u6c42\uff0c\u6027\u80fd\u66f4\u9ad8\uff0c\u4e0d\u8fc7\u5982\u679c\u8bf7\u6c42\u8fc7\u5feb\u4ecd\u7136\u4f1a\u5bfc\u81f4\u88ab\u5c4f\u853d\u3002\n\n\u603b\u7684\u6765\u8bf4\uff0c\u5f02\u6b65\u6bd4\u540c\u6b65\u66f4\u6709\u4f18\u52bf\uff0c\u6240\u4ee5\u4e0d\u4f1a\u7684\u8bdd\u53ef\u4ee5\u53bb\u5b66\u4e00\u4e0b\uff0c\u4f1a\u53d1\u73b0\u65b0\u5929\u5730\uff08\u8bef\n\n\u5982\u679c\u4f60\u4ecd\u7136\u60f3\u7ee7\u7eed\u4f7f\u7528\u540c\u6b65\u4ee3\u7801\uff0c\u8bf7\u53c2\u8003 [\u540c\u6b65\u6267\u884c\u5f02\u6b65\u4ee3\u7801](https://nemo2011.github.io/bilibili-api/#/sync-executor)\n\n# \u6a21\u5757\u4f7f\u7528\u7684\u8bf7\u6c42\u5e93\n\n\u6a21\u5757\u5728\u5141\u8bb8\u7684\u6761\u4ef6\u4e0b\uff0c\u6309\u7167 `curl_cffi` `aiohttp` `httpx` \u7684\u4f18\u5148\u7ea7\u9009\u62e9\u7b2c\u4e09\u65b9\u8bf7\u6c42\u5e93\u3002\n\n\u5982\u679c\u60f3\u8981\u6307\u5b9a\u8bf7\u6c42\u5e93\uff0c\u53ef\u4ee5\u5229\u7528 `select_client` \u8fdb\u884c\u5207\u6362\u3002\n\n``` python\nfrom bilibili_api import select_client\n\nselect_client(\"curl_cffi\") # \u9009\u62e9 curl_cffi\uff0c\u652f\u6301\u4f2a\u88c5\u6d4f\u89c8\u5668\u7684 TLS / JA3 / Fingerprint\nselect_client(\"aiohttp\") # \u9009\u62e9 aiohttp\nselect_client(\"httpx\") # \u9009\u62e9 httpx\uff0c\u4e0d\u652f\u6301 WebSocket\n```\n\ncurl_cffi \u652f\u6301\u4f2a\u88c5\u6d4f\u89c8\u5668\u7684 TLS / JA3 / Fingerprint\uff0c\u4f46\u9700\u8981\u624b\u52a8\u8bbe\u7f6e\u3002\n\n``` python\nfrom bilibili_api import request_settings\n\nrequest_settings.set(\"impersonate\", \"chrome131\") # \u7b2c\u4e8c\u53c2\u6570\u6570\u503c\u53c2\u8003 curl_cffi \u6587\u6863\n# https://curl-cffi.readthedocs.io/en/latest/impersonate.html\n```\n\n# FA\u2642Q\n\n**Q: \u5173\u4e8e API \u8c03\u7528\u7684\u6b63\u786e\u59ff\u52bf\u662f\u4ec0\u4e48\uff1f**\n\nA: \u6240\u6709 API \u8c03\u7528\uff0c\u8bf7\u5c3d\u91cf\u4f7f\u7528 **\u6307\u540d\u65b9\u5f0f** \u4f20\u53c2\uff0c\n\u56e0\u4e3a API \u8f83\u591a\uff0c\u53ef\u80fd\u4e0d\u540c\u51fd\u6570\u7684\u4f20\u53c2\u987a\u5e8f\u4e0d\u4e00\u6837\uff0c\u4f8b\u5b50\uff1a\n\n```python\n# \u63a8\u8350\nvideo.get_info(bvid=\"BV1uv411q7Mv\")\n\n# \u5f53\u7136\u4e5f\u53ef\u4ee5\u8fd9\u6837\nkwargs = {\n    \"bvid\": \"BV1uv411q7Mv\"\n}\nvideo.get_info(**kwargs)\n\n# \u4e0d\u63a8\u8350\nvideo.get_info(\"BV1uv411q7Mv\")\n```\n\n**Q: \u4e3a\u4ec0\u4e48\u4f1a\u63d0\u793a 412 Precondition Failed \uff1f**\n\nA: \u4f60\u7684\u8bf7\u6c42\u901f\u5ea6\u592a\u5feb\u4e86\u3002\u9020\u6210\u8bf7\u6c42\u901f\u5ea6\u8fc7\u5feb\u7684\u539f\u56e0\u53ef\u80fd\u662f\u4f60\u5199\u4e86\u9ad8\u5e76\u53d1\u7684\u4ee3\u7801\u3002\n\n\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u7684 IP \u4f1a\u6682\u65f6\u88ab\u5c01\u7981\u800c\u65e0\u6cd5\u4f7f\u7528\uff0c\u4f60\u53ef\u4ee5\u8bbe\u7f6e\u4ee3\u7406\u7ed5\u8fc7\u3002\n\n```python\nfrom bilibili_api import request_settings\n\nrequest_settings.set_proxy(\"http://your-proxy.com\") # \u91cc\u5934\u586b\u5199\u4f60\u7684\u4ee3\u7406\u5730\u5740\n\nrequest_settings.set_proxy(\"http://username:password@your-proxy.com\") # \u5982\u679c\u9700\u8981\u7528\u6237\u540d\u3001\u5bc6\u7801\n```\n\n**Q: \u6211\u60f3\u5728\u9879\u76ee\u4e2d\u4f7f\u7528\u8fd9\u4e2a\u6a21\u5757\uff0c\u4f46\u662f\u6211\u7684\u9879\u76ee\u4f7f\u7528\u5176\u4ed6\u8bf7\u6c42\u5e93\u8fdb\u884c\u7f51\u7edc\u8bf7\u6c42\uff08\u5982 `pycurl`\uff09\uff0c\u60f3\u8981\u6a21\u5757\u4e5f\u540c\u65f6\u4f7f\u7528\u5b83\uff08\u4eec\uff09\uff0c\u53ef\u4ee5\u5417\uff1f**\n\nA: \u53ef\u4ee5\uff0c\u4f46\u662f\u4f60\u53ef\u80fd\u8981\u81ea\u5df1\u52a8\u624b\u5b9e\u73b0\u6a21\u5757\u548c\u5177\u4f53\u8bf7\u6c42\u5e93\u7684\u9002\u914d\u3002\u8be6\u89c1 [\u81ea\u5b9a\u4e49\u8bf7\u6c42\u5e93](https://nemo2011.github.io/bilibili-api/#/request_client)\n\n**Q: \u600e\u4e48\u6ca1\u6709\u6211\u60f3\u8981\u7684\u529f\u80fd\uff1f**\n\nA: \u4f60\u53ef\u4ee5\u53d1 Issue \u6765\u63d0\u4ea4\u4f60\u7684\u9700\u6c42\uff0c\u4f46\u662f\uff0c\u6700\u597d\u7684\u529e\u6cd5\u662f\u81ea\u5df1\u5199\uff08\u61d2\uff09\n\n<span id=\"contribute\">**Q: \u6211\u6709\u4e00\u4e2a\u5927\u80c6\u7684\u60f3\u6cd5\uff0c\u5982\u4f55\u7ed9\u4ee3\u7801\u5e93\u8d21\u732e\uff1f**</span>\n\nA: \u8bf7\u5148 clone \u672c\u4ed3\u5e93\u4e00\u4efd\uff0c\u7136\u540e\u4ece main \u5206\u652f\u65b0\u5efa\u4e00\u4e2a\u5206\u652f\uff0c\u5728\u8be5\u5206\u652f\u4e0a\u5de5\u4f5c\u3002\n\u5982\u679c\u4f60\u89c9\u5f97\u5df2\u7ecf\u53ef\u4ee5\u4e86\uff0c\u8bf7\u5411\u9879\u76ee\u4ed3\u5e93\u7684 develop \u5206\u652f\u53d1\u8d77 Pull request\u3002\n\u5982\u679c\u4f60\u4e0d\u660e\u767d\u8fd9\u4e9b\u64cd\u4f5c\u7684\u8bdd\uff0c\u53ef\u4ee5\u767e\u5ea6\u3002\u5b8c\u6574\u6307\u5357\uff1a[CONTRIBUTING.md](https://github.com/nemo2011/bilibili-api/blob/main/.github/CONTRIBUTING.md)\n\n**Q: \u7a33\u5b9a\u6027\u600e\u4e48\u6837\uff1f**\n\nA: \u7531\u4e8e\u8be5\u6a21\u5757\u6bd4\u8f83\u7279\u6b8a\uff0c\u662f\u722c\u866b\u6a21\u5757\uff0c\u5982\u679c b \u7ad9\u7684\u63a5\u53e3\u53d8\u66f4\uff0c\u53ef\u80fd\u4f1a\u9a6c\u4e0a\u5931\u6548\u3002\u56e0\u6b64\u8bf7\u59cb\u7ec8\u4fdd\u8bc1\u662f\u6700\u65b0\u7248\u672c\u3002\u5982\u679c\u53d1\u73b0\u95ee\u9898\u53ef\u4ee5\u63d0 [Issues][issues-new]\u3002\n\n# \u811a\u6ce8\n\n- \\[1\\] \u8fd9\u91cc\u53ea\u5217\u51fa\u4e00\u90e8\u5206\uff0c\u8bf7\u4ee5\u5b9e\u9645 API \u4e3a\u51c6\u3002\n- \\[2\\] \u4ee3\u7801\u6765\u6e90\uff1a<https://www.zhihu.com/question/381784377/answer/1099438784> (WTFPL)\n- \\[3\\] \u90e8\u5206\u4ee3\u7801\u6765\u6e90\uff1a<https://github.com/m13253/danmaku2ass> (GPLv3) <https://github.com/ewwink/python-srt2ass>\n- \\[4\\] \u601d\u8def\u6765\u6e90\uff1a<https://socialsisteryi.github.io/bilibili-API-collect/docs/login/cookie_refresh.html> (CC-BY-NC 4.0)\n- \\[5\\] \u5927\u91cf\u601d\u8def\u6765\u6e90 <https://github.com/SocialSisterYi/bilibili-API-collect> \u4e2d\u76f8\u5173\u8ba8\u8bba\u3002\n\n[docs]: https://nemo2011.github.io/bilibili-api\n[docs-github]: https://github.com/nemo2011/bilibili-api/tree/main/docs\n[api.json]: https://github.com/nemo2011/bilibili-api/tree/main/bilibili_api/data/api/\n[license]: https://github.com/nemo2011/bilibili-api/tree/main/LICENSE\n[stargazers]: https://github.com/nemo2011/bilibili-api/stargazers\n[issues-new]: https://github.com/Nemo2011/bilibili-api/issues/new/choose\n[get-credential]: https://nemo2011.github.io/bilibili-api/#/get-credential\n[pypi]: https://pypi.org/project/bilibili-api-python\n[pypi-dev]: https://pypi.org/project/bilibili-api-dev\n\n# Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=Nemo2011/bilibili-api&type=Date)](https://star-history.com/#Nemo2011/bilibili-api&Date)\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "The fork of module bilibili-api. \u54d4\u54e9\u54d4\u54e9\u7684\u5404\u79cd API \u8c03\u7528\u4fbf\u6377\u6574\u5408\uff08\u89c6\u9891\u3001\u52a8\u6001\u3001\u76f4\u64ad\u7b49\uff09\uff0c\u53e6\u5916\u9644\u52a0\u4e00\u4e9b\u5e38\u7528\u7684\u529f\u80fd\u3002",
    "version": "17.4.0",
    "project_urls": null,
    "split_keywords": [
        "bilibili",
        " api",
        " spider"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "791d71e2a56f25effbc4e2618a49e55015928748a1c47dda3271d9274cf1f206",
                "md5": "62e990430053db6e354db76b676b3296",
                "sha256": "79881aa011c23d74c0562765aee707d5fc410a02649091ec6aecf83f990fbdc5"
            },
            "downloads": -1,
            "filename": "bilibili_api_python-17.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "62e990430053db6e354db76b676b3296",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 385523,
            "upload_time": "2025-10-08T05:26:33",
            "upload_time_iso_8601": "2025-10-08T05:26:33.753408Z",
            "url": "https://files.pythonhosted.org/packages/79/1d/71e2a56f25effbc4e2618a49e55015928748a1c47dda3271d9274cf1f206/bilibili_api_python-17.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "54b3ca6c715311d80604ad37437bc1422c4bec7159db6ab49a311478f38e45ed",
                "md5": "f41888c50a1cb4f30437aeb5d6b208b5",
                "sha256": "396310c1820fd931a46a10c6115233be250e8db315a266eea608c0f625cdf1ef"
            },
            "downloads": -1,
            "filename": "bilibili_api_python-17.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f41888c50a1cb4f30437aeb5d6b208b5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 1417870,
            "upload_time": "2025-10-08T05:26:35",
            "upload_time_iso_8601": "2025-10-08T05:26:35.474871Z",
            "url": "https://files.pythonhosted.org/packages/54/b3/ca6c715311d80604ad37437bc1422c4bec7159db6ab49a311478f38e45ed/bilibili_api_python-17.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-08 05:26:35",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "bilibili-api-python"
}
        
Elapsed time: 2.50024s