# Bilibili Scraper｜B站视频信息/UP主资料/弹幕 (`ahuang/bilibili-video-comments-danmaku-scraper`) Actor

Scrape public Bilibili video metadata, uploader profiles and danmaku as JSON for KOL analysis, trends and AI agents. No login, pay per result. 抓取B站公开视频信息、UP主资料和弹幕，输出JSON，不登录按条计费。

- **URL**: https://apify.com/ahuang/bilibili-video-comments-danmaku-scraper.md
- **Developed by:** [HehuanHuang](https://apify.com/ahuang) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.40 / 1,000 video metadata｜视频信息

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/running/actors-in-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｜B站视频信息/UP主资料/弹幕

[English](#english) | [中文](#中文)

### English

**Bilibili Scraper – video metadata, uploader profiles & danmaku**

#### Introduction

Extract public Bilibili (B站) data with plain HTTP: no browser and no login. Each result is one dataset row, and the `type` field tells you what kind of result it is.

#### Supported data

- ✅ Video metadata: title, description, uploader, publish time, duration, views, likes, coins, favorites, shares, tags, and multi-part (分P) info
- ✅ Uploader (UP主) profiles: followers and basic stats
- ✅ Danmaku: bullet comments with in-video timestamps, from the public endpoint. **This is a partial sample, not the full danmaku history.**
- ⚠️ Comments (limited): guests get only 3–4 top-level comments per video. Replies can be fetched.
- ⚠️ Subtitles (limited): most videos require login, so subtitles are usually unavailable. When none are returned, a free `notice` row is written instead.

#### Use cases

- UP主 / KOL analysis: compare reach and engagement before sponsorships
- Trend and content research: views, tags and danmaku timing
- AI agents and LLM tools: structured Bilibili metadata as context
- Brand monitoring: danmaku reactions on product videos

#### Input

| Field | Description |
|---|---|
| `startUrls` | Video URLs, b23.tv short links, BV or av IDs (required, batch) |
| `dataTypes` | `video`, `comments`, `danmaku`, `subtitles`, `profile` (default `video`) |
| `maxCommentsPerVideo` | Default 100. Guests actually get only ~3–4. |
| `includeReplies` / `maxRepliesPerComment` | Replies (楼中楼). Default off / 10 per comment. |
| `maxDanmakuPerVideo` | Per part, default 500 (partial sample, not full history) |
| `allPages` | Every part of multi-part videos. **Default on: danmaku/subtitle charges multiply by the number of parts.** |
| `subtitleFormat` | `markdown` / `text` / `srt` / `json` |
| `maxConcurrency` | 1–5, default 3 |

#### Output example (example only)

```json
{"type":"video","input":"BV1GJ411x7h7","bvid":"BV1GJ411x7h7","aid":80433022,"title":"示例视频","owner":{"mid":123456,"name":"示例UP主"},"stats":{"view":120000,"like":8000,"coin":2100,"favorite":3500,"share":300,"reply":640,"danmaku":1900},"duration_sec":615,"published_at":"2026-10-01T12:00:00+08:00","tags":["音乐"],"pages":[{"page":1,"cid":1176840,"title":"P1","duration_sec":300}]}
{"type":"danmaku","input":"BV1GJ411x7h7","bvid":"BV1GJ411x7h7","page":1,"cid":1176840,"time_sec":12.5,"mode":"scroll","color":"#ffffff","sent_at":"2026-10-02T08:00:00+08:00","text":"前方高能"}
{"type":"notice","input":"BV1GJ411x7h7","bvid":"BV1GJ411x7h7","page":1,"cid":1176840,"dataType":"subtitles","notice":"no subtitle returned to guest (bilibili says login required for subtitles)"}
```

#### Pricing (pay per event)

| Output `type` | Charged event | Price per item |
|---|---|---|
| `video` | `video` | $0.003 |
| `profile` | `user-profile` | $0.003 |
| `comment` | `comment` | $0.001 |
| `danmaku` | `danmaku` | $0.0005 |
| `subtitle` | `subtitle-track` | $0.003 |
| `notice`, `error` | — | **Free** |

You are charged only for rows actually returned. With `allPages` on, danmaku and subtitles are fetched (and charged) for every part.

Optional subscription tiers (if enabled on the Store): SILVER 10% off, GOLD and above 20% off. Danmaku may skip tier discounts.

#### Notes

- Public data only. No login and no video downloads.
- Danmaku is a partial sample from the public endpoint, not full history. Comments and subtitles are limited for guests.
- Bilibili rate-limits requests (HTTP 412). The Actor throttles itself and retries.
- You are responsible for complying with Bilibili's Terms of Service and applicable laws.

### 中文

**B站数据工具：视频信息、UP主资料、弹幕**

#### 简介

纯 HTTP 抓取 B站公开数据，不开浏览器，也不登录。每条结果一行，用 `type` 字段区分类型。

#### 支持的数据类型

- ✅ 视频信息：标题、简介、UP主、发布时间、时长、播放、点赞、投币、收藏、分享、标签、分P信息
- ✅ UP主资料：粉丝数和基础数据
- ✅ 弹幕：带视频内时间点，来自公开接口。**只是部分样本，不是全部历史弹幕。**
- ⚠️ 评论（有限支持）：未登录时每个视频只返回 3–4 条一级评论，楼中楼可以抓到。
- ⚠️ 字幕（有限支持）：大多数视频的字幕需要登录，通常拿不到。拿不到时写一条不扣费的 `notice` 记录。

#### 用例

- UP主/KOL 分析：投放合作前比较影响力和互动数据
- 趋势和内容研究：播放量、标签、弹幕出现的时间点
- AI 智能体、大模型工具：提供结构化的 B站元数据作为上下文
- 品牌监测：产品视频下的弹幕反应

#### 输入

| 字段 | 说明 |
|---|---|
| `startUrls` | 视频链接、b23.tv 短链、BV 号或 av 号（必填，可批量） |
| `dataTypes` | `video`、`comments`、`danmaku`、`subtitles`、`profile`（默认只抓 `video`） |
| `maxCommentsPerVideo` | 默认 100，未登录时实际只有约 3–4 条 |
| `includeReplies` / `maxRepliesPerComment` | 楼中楼，默认关闭；每条评论最多抓 10 条回复 |
| `maxDanmakuPerVideo` | 每个分P的上限，默认 500（部分样本，不是全部历史） |
| `allPages` | 多P视频抓全部分P。**默认开启：弹幕/字幕按分P数成倍计费。** |
| `subtitleFormat` | `markdown` / `text` / `srt` / `json` |
| `maxConcurrency` | 1–5，默认 3 |

#### 输出示例（示例）

同英文部分的 JSON。

#### 定价（按事件计费）

| 输出 `type` | 扣费事件 | 单价 |
|---|---|---|
| `video` | `video` | $0.003 |
| `profile` | `user-profile` | $0.003 |
| `comment` | `comment` | $0.001 |
| `danmaku` | `danmaku` | $0.0005 |
| `subtitle` | `subtitle-track` | $0.003 |
| `notice`、`error` | — | **免费** |

只对实际返回的记录扣费。`allPages` 开启时，每个分P都会抓取并计费弹幕和字幕。

可选订阅阶梯（若 Store 上启用）：SILVER 9 折，GOLD 及以上 8 折；弹幕可不分档。

#### 注意

- 只抓公开数据，不登录，不下载视频。
- 弹幕是公开接口给的部分样本，不是全部历史；评论和字幕在未登录时有限。
- B站有 412 限流，工具内置了限速和重试。
- 使用者需要自行遵守 B站用户协议和相关法律。

# Actor input Schema

## `startUrls` (type: `array`):

B站视频链接、b23.tv 短链、BV 号或 av 号，可批量；只接受 bilibili.com / b23.tv。Bilibili video URLs, b23.tv short links, BV or av ids (batch). Only bilibili.com / b23.tv accepted.

## `dataTypes` (type: `array`):

每个视频要抓取的数据。What to scrape for each video.

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

默认 100，但未登录时 B站实际只返回约 3–4 条一级评论。Default 100, but guests actually get only ~3–4 top-level comments from Bilibili.

## `includeReplies` (type: `boolean`):

同时抓取评论下的回复。Also fetch replies under each comment.

## `maxRepliesPerComment` (type: `integer`):

每条一级评论最多抓多少回复。Max replies fetched per top-level comment.

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

公开 XML 接口，按视频内时间排序。公开接口只提供部分弹幕，不是全部历史。Public XML endpoint, sorted by in-video time. Partial sample, not full history.

## `subtitleFormat` (type: `string`):

markdown（带时间戳）、纯文本、SRT 或分段 JSON。Markdown with timestamps, plain text, SRT or segment JSON.

## `allPages` (type: `boolean`):

多P视频的每个分P都抓弹幕和字幕。默认开启：分P越多，计费成倍增加。Danmaku/subtitles for every part of multi-part videos. Default on: charges multiply by the number of parts.

## `maxConcurrency` (type: `integer`):

建议保持较低以避免 412 限流。Keep low to avoid HTTP 412 rate limits.

## Actor input object example

```json
{
  "startUrls": [
    "BV1xx411c7mD"
  ],
  "dataTypes": [
    "video"
  ],
  "maxCommentsPerVideo": 100,
  "includeReplies": false,
  "maxRepliesPerComment": 10,
  "maxDanmakuPerVideo": 500,
  "subtitleFormat": "markdown",
  "allPages": true,
  "maxConcurrency": 3
}
```

# Actor output Schema

## `results` (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 = {
    "startUrls": [
        "BV1xx411c7mD"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ahuang/bilibili-video-comments-danmaku-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 = { "startUrls": ["BV1xx411c7mD"] }

# Run the Actor and wait for it to finish
run = client.actor("ahuang/bilibili-video-comments-danmaku-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 '{
  "startUrls": [
    "BV1xx411c7mD"
  ]
}' |
apify call ahuang/bilibili-video-comments-danmaku-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ahuang/bilibili-video-comments-danmaku-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/I9sWBuJ1345TEHaQ9/builds/KwgLuoy21lFid8jJa/openapi.json
