# Bilibili Comments Scraper 哔哩哔哩评论采集 - Replies & Pinned (`alomost/bilibili-comments-scraper`) Actor

Scrape Bilibili (哔哩哔哩, B站) comments by keyword or video URL: full reply threads (楼中楼) paginated to the end, pinned comments, likes, user level. No login. Export JSON/CSV/Excel or use via API. AI-agent friendly. 无需登录，评论、回复、置顶一次导出。

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

## Pricing

from $2.00 / 1,000 comment scrapeds

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 Comments Scraper 哔哩哔哩评论采集 — Replies & Pinned

Scrape comments from **Bilibili (哔哩哔哩, B站)**, China's biggest video platform for games, anime and tech, by **keyword** or by **video URL / BV ID**. You get the **whole conversation in one dataset**: root comments, **every nested reply (楼中楼) paginated to the end**, the **pinned (置顶) comment**, likes, user level and timestamps.

No login. No cookies. No browser. Export to **JSON, CSV or Excel**, or call it via API — AI-agent friendly.

### What you get

- **Full threads**: sub-replies are fetched page by page until the thread ends, not just the 3 previews shown under each comment.
- **Thread structure on every row**: `comment_type` (root / sub), `root_rpid` and `parent_rpid`, so you can rebuild who answered whom.
- **Pinned comment** included and de-duplicated.
- **Keyword mode**: search videos (relevance, most played, newest, most danmaku, most favorited) and pull comments from the top N.
- **Privacy switch**: `anonymizeUsers` replaces names and user IDs with stable hashes.

### Pricing

Pay per result: **$3 per 1,000 comments or replies** on the Free plan, down to **$2 per 1,000** on Gold and above. No monthly fee.

| Task | Rows | Approx. cost (Free plan) |
|---|---|---|
| 1 video, 100 root comments + replies | ~300 | ~$0.90 |
| 5 keywords × 5 videos × 100 comments, no replies | ~2,500 | ~$7.50 |
| 1 viral video, 2,000 root comments + replies | ~6,000 | ~$18 |

Tip: set `includeSubReplies` off or lower `maxSubRepliesPerComment` to control cost.

### Use cases

- **Game & app teams**: read what Chinese players say about your game, launch or patch. Example input: `{"keywords": ["黑神话 差评"], "maxVideosPerKeyword": 5, "commentSort": "hot"}`
- **Brand & KOL monitoring (舆情监测)**: track reactions to a product, campaign or creator video.
- **Market research & AI datasets**: clean Chinese conversational data with thread structure for sentiment analysis or LLM fine-tuning.

### Input

| Field | Description |
|---|---|
| `keywords` | Search terms, e.g. `原神`, `空洞骑士 差评` |
| `videoUrls` | Video URLs, `BV1...` IDs, `av123` or numeric aid |
| `maxVideosPerKeyword` | Videos to take per keyword (default 5) |
| `searchOrder` | Relevance, most played, newest, most danmaku, most favorited |
| `maxCommentsPerVideo` | Root comments per video (default 100) |
| `commentSort` | `hot` (same as website) or `time` |
| `includeSubReplies` | Fetch all 楼中楼 (default on) |
| `maxSubRepliesPerComment` | Cap per root comment (default 200) |
| `anonymizeUsers` | Replace names and IDs with stable hashes |
| `proxyConfiguration` | Optional; use if you see 412 / -352 errors |

### Output (one row per comment)

```json
{
  "video_bvid": "BV1hGW76hEko",
  "video_title": "…",
  "video_url": "https://www.bilibili.com/video/BV1hGW76hEko",
  "comment_type": "sub",
  "is_pinned": false,
  "rpid": 319589234689,
  "root_rpid": 319587388497,
  "parent_rpid": 319587388497,
  "user_name": "…",
  "user_mid": "…",
  "user_level": 6,
  "like": 12,
  "reply_count": null,
  "created_at": "2026-11-05T09:12:00+00:00",
  "ip_location": "广东",
  "text": "…"
}
```

`comment_type` is `root` or `sub`. Rebuild threads with `root_rpid`; `parent_rpid` tells you who a sub-reply answers.

### FAQ

**I get 412 or -352 errors.** Bilibili rate-limits busy IPs. Turn on `proxyConfiguration` (Apify residential works best) and retry.

**How do I get Excel?** Open the run's dataset and click Export → Excel (or CSV / JSON).

**Why fewer comments than the video shows?** Bilibili's count includes deleted and folded comments, which are not public.

### Notes

- `ip_location` is filled only when Bilibili exposes it; for logged-out requests it is usually empty.
- Only public data is collected. Respect Bilibili's terms and the privacy laws that apply to you (incl. China's PIPL); turn on `anonymizeUsers` if you don't need identities.

***

### 中文说明

**B站评论爬取 / 哔哩哔哩评论采集**：按关键词或视频链接、BV号抓取 B站 视频评论，**楼中楼回复翻页抓全**，包含**置顶评论**、点赞数、用户等级和发布时间。无需登录、无需 cookie，可导出 Excel / CSV / JSON，也可通过 API 调用。

- 每条评论一行，`comment_type` 区分主评论和楼中楼，`root_rpid` / `parent_rpid` 还原楼层与回复关系
- 关键词模式：按综合、播放、最新、弹幕、收藏排序选视频
- `anonymizeUsers` 一键昵称和 ID 脱敏
- 价格：每 1,000 条 $3（免费套餐），Gold 及以上 $2

适合：游戏团队看玩家反馈和差评、品牌与 UP 主舆情监测、中文语料与情感分析数据集。

# Actor input Schema

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

Search Bilibili videos by keyword (Chinese works best, e.g. 原神). Leave empty if you give video URLs.

## `videoUrls` (type: `array`):

Bilibili video URLs, BV IDs (BV1xx...), av IDs (av123) or numeric aid.

## `maxVideosPerKeyword` (type: `integer`):

How many videos to take from the search results of each keyword.

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

How Bilibili sorts the keyword search results.

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

Maximum number of root (top-level) comments per video. Pinned comment counts as one.

## `commentSort` (type: `string`):

Hot = same order as the website. Newest = most recent first.

## `includeSubReplies` (type: `boolean`):

Fetch every nested reply under each root comment. Slower, more results.

## `maxSubRepliesPerComment` (type: `integer`):

Maximum nested replies (楼中楼) fetched under each root comment.

## `anonymizeUsers` (type: `boolean`):

Replace user names and IDs with a stable hash.

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

Optional. Bilibili usually works without proxy; use one if you get 412 errors.

## Actor input object example

```json
{
  "keywords": [
    "原神"
  ],
  "maxVideosPerKeyword": 5,
  "searchOrder": "totalrank",
  "maxCommentsPerVideo": 100,
  "commentSort": "hot",
  "includeSubReplies": true,
  "maxSubRepliesPerComment": 200,
  "anonymizeUsers": false,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `comments` (type: `string`):

All scraped comments and sub-replies, one row per comment.

# 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": [
        "原神"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("alomost/bilibili-comments-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": ["原神"],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("alomost/bilibili-comments-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": [
    "原神"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call alomost/bilibili-comments-scraper --silent --output-dataset

```

## MCP server setup

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