# Bilibili Scraper — Videos, Comments & Danmaku (`alias_md5/bilibili-scraper`) Actor

B站（哔哩哔哩）一站式数据采集器：快速批量抓取视频搜索结果、完整播放/点赞/投币/收藏数据、视频评论、全量弹幕、热门榜单与UP主主页，导出干净 JSON/CSV/Excel。Scrape Bilibili videos, search, comments, danmaku, trends & creator profiles from $0.50/1k.

- **URL**: https://apify.com/alias_md5/bilibili-scraper.md
- **Developed by:** [Alias Data Studio](https://apify.com/alias_md5) (community)
- **Categories:** Social media, Videos, AI
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 search video / 搜索视频结果

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Bilibili Scraper — Videos, Comments & Danmaku

**B站（哔哩哔哩）一站式数据采集器**：批量抓取视频搜索结果、完整播放/点赞/投币/收藏/分享数据、视频评论、全量时间戳弹幕、热门榜单与 UP 主主页，直接导出干净规范的 **JSON / CSV / Excel**。

**All-in-one Bilibili data scraper**: extract keyword video search results, full video engagement stats, audience comments, timestamped danmaku (弹幕 / bullet comments), trending rankings, and creator (UP主) profiles into clean **JSON, CSV, or Excel**.

***

### Why Choose Bilibili Scraper / 核心亮点

- **一站式覆盖 / All-in-one**：一个工具覆盖 B 站视频搜索、视频详情、评论、全量弹幕（Danmaku）、热门榜单与 UP 主（Creator）主页数据。
- **高性价比 / Cost-effective**：按实际交付条数透明计费，视频低至 **$0.50 / 1,000 条**、弹幕低至 **$0.02 / 1,000 条**——空跑或报错不收费（errors & empty results are never charged）。
- **实打实附赠 / Bonus included**：抓取视频详情时可勾选**免费附赠前 5 条热门评论**，不另计评论费用（top 5 comments included free with video details）。
- **稳定省心、开箱即用 / Reliable & ready to use**：开箱即用、无需额外配置；标题已自动清理高亮标签，时间统一为 ISO 格式、时长统一为秒数，拿到即可做数据分析或喂给 AI。

***

### Common Use Cases / 适用场景

- **舆情与品牌监控 / Brand & Sentiment Monitoring**：按关键词批量采集视频、评论与弹幕，追踪消费者对产品、品牌或行业事件的真实反馈。
- **爆款选题与竞品分析 / Content Research & Benchmarking**：对比不同关键词下的播放、投币、收藏、弹幕与点赞转化率，筛选高互动选题。
- **UP 主追踪与达人筛选 / Creator (UP主) Discovery**：批量查询 UP 主粉丝数、投稿量、总获赞与认证头衔，辅助达人投放与 MCN 选号。
- **弹幕情绪与时间轴分析 / Timeline Danmaku Analysis**：按精确到秒的 `videoTimestampSeconds` 定位视频高能片段与观众情绪波动点。
- **AI Agent 与 RAG 语料 / AI Agents & Datasets**：结构化 JSON 输出，可直接接入 Apify MCP Server 供 Claude、Cursor、ChatGPT 或自研 Agent 调用。

***

### Supported Modes / 支持的采集模式

| Mode / 模式 | Required Input / 输入参数 | What You Get / 返回数据 |
| --- | --- | --- |
| `search`（关键词搜视频） | `keywords`, `searchOrder`, `maxItemsPerQuery` | 视频 BVID、干净标题、简介、UP 主信息、播放/点赞/弹幕/收藏/评论数、标签、时长（秒）、发布时间与直达链接；可选附带完整视频详情。 |
| `video`（视频详情） | `bvids`（支持完整视频链接或 BVID） | 完整互动指标（播放、点赞、投币、收藏、分享、评论、历史排名）、分区、分 P 章节列表，以及可选**免费附赠前 5 条热门评论**；批量任务中个别失效/删除视频自动跳过不中断整批。 |
| `comments`（视频评论） | `bvids`, `maxCommentsPerVideo`, `commentSortMode` | 开箱自动翻页抓取视频评论（单视频最高支持 **2,000 条**，支持按**最热 `hot` / 最新 `newest`** 排序）：包含评论内容、作者昵称与 UID、等级、点赞数、回复数、发布时间与 IP 属地；无需填写 `sessdata` 即可多页采集（特殊场景下仍支持选填加密 `sessdata`）。 |
| `danmaku`（视频弹幕） | `bvids`, `maxDanmakuPerVideo` | 全量时间戳弹幕：`videoTimestampSeconds`（视频内秒数）、`text`（弹幕文本）、`colorHex`（颜色）、`mode`（滚动/顶部/底部模式）、发送时间与发送者哈希（默认即可全量获取数百至上千条/视频）。 |
| `popular`（热门榜单） | `maxItemsPerQuery` | 当前 B 站热门榜排名、推荐理由、发布属地、UP 主信息与完整互动数据（支持多页连续抓取）。 |
| `creator`（UP主主页） | `creatorMids`（支持主页链接或 MID） | UP 主昵称、简介、官方认证头衔、等级、粉丝数、关注数、视频投稿数与总获赞数。 |

***

### Transparent Pricing / 透明按量计费

按**实际成功交付的数据条数**计费，付费套餐自动享受阶梯折扣（空跑或失败条数不扣费）：

| Event / 计费项 | Free | Bronze | Silver | Gold / Enterprise |
| --- | ---: | ---: | ---: | ---: |
| **Search / Trending Video（搜索/热门视频，每 1,000 条）** | `$1.00` | `$0.80` | `$0.65` | `$0.50` |
| **Video Detail / Creator Profile（视频详情/UP主主页，每 1,000 条）** | `$2.00` | `$1.60` | `$1.30` | `$1.00` |
| **Video Comment（独立评论抓取，每 1,000 条）** | `$1.50` | `$1.10` | `$0.90` | `$0.70` |
| **Video Danmaku（视频弹幕，每 1,000 条）** | `$0.05` | `$0.04` | `$0.03` | `$0.02` |

> **说明 / Note**：在 `video`（或开启 `shouldIncludeVideoDetails` 的 `search`）模式下勾选 `shouldIncludeCommentsPreview` 附带的前 5 条热门评论完全免费，不会触发 `bilibili-comment-item` 计费。

***

### Example Inputs / 输入示例

#### 1. 关键词搜视频 / Keyword Video Search (`mode: "search"`)

```json
{
  "mode": "search",
  "keywords": ["AI", "NVIDIA", "人工智能"],
  "searchOrder": "click",
  "maxItemsPerQuery": 40
}
```

#### 2. 全量视频弹幕 / Video Danmaku (`mode: "danmaku"`)

```json
{
  "mode": "danmaku",
  "bvids": ["https://www.bilibili.com/video/BV1xE421j7Uv"],
  "maxDanmakuPerVideo": 500
}
```

#### 3. 视频评论 / Video Comments (`mode: "comments"`)

```json
{
  "mode": "comments",
  "bvids": ["https://www.bilibili.com/video/BV1xE421j7Uv"],
  "maxCommentsPerVideo": 100,
  "commentSortMode": "hot"
}
```

> **说明 / Note**：开箱支持自动翻页抓取（单视频最高 **2,000 条**评论，支持按最热 `hot` 或最新 `newest` 排序），直接粘贴完整 `https://www.bilibili.com/video/BV...` 视频链接或 `BV...` 编号即可。`sessdata` 仅在特殊场景下作为可选加密字段提供，常规翻页采集无需配置。

#### 4. 视频详情 + 免费附赠热评 / Video Details (`mode: "video"`)

```json
{
  "mode": "video",
  "bvids": ["BV1xE421j7Uv"],
  "shouldIncludeCommentsPreview": true
}
```

#### 5. 热门榜单 / Trending Feed (`mode: "popular"`)

```json
{
  "mode": "popular",
  "maxItemsPerQuery": 40
}
```

#### 6. UP 主主页资料 / Creator Profile (`mode: "creator"`)

```json
{
  "mode": "creator",
  "creatorMids": ["https://space.bilibili.com/14871346"]
}
```

***

### Example Outputs / 输出数据示例

#### 视频搜索结果 / Video Search Record

```json
{
  "recordType": "search_video",
  "queryKeyword": "NVIDIA",
  "bvid": "BV1xE421j7Uv",
  "aid": 1653810007,
  "title": "【硬核科普】从零开始认识显卡",
  "videoUrl": "https://www.bilibili.com/video/BV1xE421j7Uv",
  "durationSeconds": 920,
  "publishedAtIso": "2024-05-01T03:00:00.000Z",
  "creator": {
    "mid": 14871346,
    "name": "硬件茶谈",
    "profileUrl": "https://space.bilibili.com/14871346"
  },
  "viewCount": 5433866,
  "danmakuCount": 9741,
  "commentCount": 5852,
  "favoriteCount": 294194,
  "likeCount": 434362
}
```

#### 弹幕记录 / Danmaku Record

```json
{
  "recordType": "danmaku",
  "bvid": "BV1xE421j7Uv",
  "cid": 1537807778,
  "videoTitle": "【硬核科普】从零开始认识显卡",
  "videoTimestampSeconds": 28.019,
  "mode": 1,
  "colorHex": "#ffffff",
  "sentAtIso": "2024-05-01T04:44:41.000Z",
  "senderHash": "50eeaa07",
  "text": "百万动画"
}
```

#### 评论记录 / Comment Record

```json
{
  "recordType": "comment",
  "bvid": "BV1xE421j7Uv",
  "videoTitle": "【硬核科普】从零开始认识显卡",
  "totalCommentCount": 5852,
  "commentId": 300020267296,
  "authorMid": 650513025,
  "authorName": "海晶666",
  "authorLevel": 5,
  "message": "22岁，自己攒钱买的第一张显卡",
  "likeCount": 687,
  "replyCount": 90,
  "createdAtIso": "2026-04-24T08:08:17.000Z",
  "relativeTimeText": "216天前发布"
}
```

***

### Quick Integration: API, MCP & n8n / 快速集成（API / MCP / n8n）

#### Python (`apify-client`)

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("alias_md5/bilibili-scraper").call(run_input={
    "mode": "search",
    "keywords": ["AI", "NVIDIA"],
    "searchOrder": "click",
    "maxItemsPerQuery": 40,
})
items = list(client.dataset(run["defaultDatasetId"]).iterate_items())
print(f"Fetched {len(items)} Bilibili records")
```

#### Node.js (`apify-client`)

```javascript
import { ApifyClient } from "apify-client";

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor("alias_md5/bilibili-scraper").call({
  mode: "danmaku",
  bvids: ["https://www.bilibili.com/video/BV1xE421j7Uv"],
  maxDanmakuPerVideo: 500,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.slice(0, 3));
```

#### AI Agents (Apify MCP Server) / 接入 Claude、Cursor 与 AI Agent

本采集器开箱兼容 **Apify MCP Server**，可在 Claude Desktop、Cursor 或自定义 Agent 中直接配置并按需调用：

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com/?actors=alias_md5/bilibili-scraper",
      "headers": {
        "Authorization": "Bearer <YOUR_APIFY_TOKEN>"
      }
    }
  }
}
```

#### n8n Workflow / n8n 自动化工作流

1. 在 n8n 中添加官方 **Apify** 节点（`@apify/n8n-nodes-apify`），选择 **Run Actor** 并填入 `alias_md5/bilibili-scraper`。
2. 粘贴任意模式的 JSON 输入（如定时抓取 `mode: "popular"` 热门榜或关键词搜索 `mode: "search"`）。
3. 下游连接 **Get Dataset Items** 节点，直接将干净的结构化数据写入 Google Sheets、Notion、飞书、Slack 或 LLM 节点做自动舆情分析。

***

### FAQ / 常见问题

- **支持直接粘贴完整 B 站链接吗？** 支持。`bvids` 接受完整视频 URL（`https://www.bilibili.com/video/BV...`）或裸 `BV` 号，`creatorMids` 接受完整 UP 主空间 URL（`https://space.bilibili.com/...`）或数字 UID，均会自动去重。
- **批量采集遇到失效或已删除视频会中断吗？** 不会。失效目标会自动跳过且不计费，同时记录在 Key-Value Store 的 `RUN_SUMMARY` 中，其余有效目标照常完成。
- **支持导出哪些格式？** 所有模式输出统一的结构化数据，可在 Apify Console 或 API 一键导出为 **JSON、CSV、Excel、XML 或 RSS**。

# Actor input Schema

## `mode` (type: `string`):

Choose what Bilibili data to extract / 选择需要采集的 B 站数据类型。

## `keywords` (type: `array`):

Keywords for Video Search mode (e.g. 'AI', 'NVIDIA', '人工智能') / 关键词搜视频模式下的搜索词列表。

## `searchOrder` (type: `string`):

Sort order for video search results / 视频搜索结果排序方式。

## `maxItemsPerQuery` (type: `integer`):

Maximum number of videos to scrape per keyword or in Trending mode / 每个搜索词或热门榜单最多抓取的视频数量。

## `bvids` (type: `array`):

Accepts full Bilibili video URLs (https://www.bilibili.com/video/BV...) or bare BVIDs (BV1xE421j7Uv), automatically deduplicated / 支持直接粘贴完整 B 站视频链接或 BVID，自动提取并去重。

## `maxCommentsPerVideo` (type: `integer`):

Maximum number of comments to extract per video (paginates automatically up to 2,000 comments per video out of the box) / 评论模式下每个视频最多抓取的评论条数（开箱自动翻页，单视频支持抓取最多 2,000 条评论）。

## `commentSortMode` (type: `string`):

Choose whether to fetch most popular (hot) or newest comments in Comments mode / 评论模式下选择按最热或最新排序抓取。

## `maxDanmakuPerVideo` (type: `integer`):

Maximum number of timestamped danmaku (bullet comments) to extract per video (hundreds to thousands available per video out of the box) / 弹幕模式下每个视频最多抓取的弹幕条数（单视频默认即可获取数百至上千条时间戳弹幕）。

## `creatorMids` (type: `array`):

Accepts full creator space URLs (https://space.bilibili.com/14871346) or numeric MIDs (14871346), automatically deduplicated / 支持直接粘贴 UP 主主页链接或数字 UID（MID），自动提取并去重。

## `shouldIncludeVideoDetails` (type: `boolean`):

In Search mode, fetch full engagement metrics (coins, shares, chapters) for each video / 开启后为每条搜索结果补充投币、分享、分P等完整视频详情。

## `shouldIncludeCommentsPreview` (type: `boolean`):

Attach top 5 popular comments at no extra cost when scraping Video Details / 抓取视频详情时免费附赠前 5 条热门评论，不另计评论费用。

## `sessdata` (type: `string`):

Not required for standard paginated comments (up to 2,000/video). Optional encrypted cookie only if needed for special or account-restricted cases; never logged or written to outputs / 标准翻页抓取评论（最多 2,000 条/视频）无需填写；仅在特殊场景下选填，严格加密且绝不写入日志或结果。

## `requestMinIntervalMs` (type: `integer`):

Minimum delay in milliseconds between consecutive requests / 连续请求之间的最小等待毫秒数。

## `proxyConfiguration` (type: `object`):

Default routing configuration for reliable runs (enabled automatically) / 默认已开启稳定路由配置，一般无需修改。

## Actor input object example

```json
{
  "mode": "search",
  "keywords": [
    "AI",
    "NVIDIA"
  ],
  "searchOrder": "totalrank",
  "maxItemsPerQuery": 40,
  "bvids": [
    "https://www.bilibili.com/video/BV1xE421j7Uv"
  ],
  "maxCommentsPerVideo": 100,
  "commentSortMode": "hot",
  "maxDanmakuPerVideo": 500,
  "creatorMids": [
    "https://space.bilibili.com/14871346"
  ],
  "shouldIncludeVideoDetails": false,
  "shouldIncludeCommentsPreview": false,
  "requestMinIntervalMs": 250,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `runSummary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "keywords": [
        "AI",
        "NVIDIA"
    ],
    "bvids": [
        "https://www.bilibili.com/video/BV1xE421j7Uv"
    ],
    "creatorMids": [
        "https://space.bilibili.com/14871346"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("alias_md5/bilibili-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "keywords": [
        "AI",
        "NVIDIA",
    ],
    "bvids": ["https://www.bilibili.com/video/BV1xE421j7Uv"],
    "creatorMids": ["https://space.bilibili.com/14871346"],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("alias_md5/bilibili-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "keywords": [
    "AI",
    "NVIDIA"
  ],
  "bvids": [
    "https://www.bilibili.com/video/BV1xE421j7Uv"
  ],
  "creatorMids": [
    "https://space.bilibili.com/14871346"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call alias_md5/bilibili-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,alias_md5/bilibili-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/VwKw1Juv0fXNcMhm2/builds/IfakYoCZhORb9g8I0/openapi.json
