# Bilibili Scraper - Videos, Creators, Comments, Danmaku (`ai-lead-gen-tools/bilibili-scraper`) Actor

\[💰$0.02/1K] Scrape Bilibili video search, creator profiles and uploads, comments and danmaku in seven modes. Every row keeps view, like, favourite and coin counts with tags, duration, owner, category and a stable resultId for dedupe. Public web API, no proxy, no cookies, no login.

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

## Pricing

from $0.02 / 1,000 video 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 Scraper - Videos, Creators, Comments, Danmaku

Scrape Bilibili through the same public web API the site itself calls, over plain HTTP with no proxy, no cookies, no account and no API key. Seven input modes cover keyword search, a single video, a creator and the whole upload list, the popular feed, the ranking board, comments and danmaku.

Search walks six sort orders and unions them, because one order alone plateaus at **288** distinct videos while all six together return **1144 to 1199** for a single keyword. Creator mode reads the upload list at 50 videos per request and follows it to the end: **683 of 683** videos on the reference channel. Every row carries a stable `resultId`, so repeated runs deduplicate.

> **BILIBILI CAPS COMMENTS AND DANMAKU ON THE SERVER SIDE.** Comments yield nine distinct root comments per video plus up to twenty replies under each, and the danmaku file is cut by the server maxlimit and by four available segment pages. The actor reports those caps per target instead of hiding them.

### What you get

| Field | Description |
|---|---|
| `resultId` | Stable id built from the mode and the entity, used to deduplicate runs |
| `kind` | Which mode produced the row: `search`, `video`, `creator`, `popular`, `ranking`, `comment`, `danmaku` |
| `status` | `ok` for a real row, or a diagnostic status when the target returned nothing |
| `reason` | Explanation attached to a diagnostic row, `null` on a normal row |
| `bvid` | Bilibili video id, the one the site puts in its own URLs |
| `aid` | Numeric legacy video id |
| `cid` | Part id, filled when the row belongs to one part of a multi-part video |
| `title` | Video title as published |
| `description` | Video description as published, with the source line breaks preserved |
| `url` | Canonical video URL |
| `cover` | Cover image URL |
| `durationSeconds` | Duration in seconds |
| `publishedAt` | Publish time in ISO 8601 |
| `tid` | Numeric category id |
| `tname` | Category name in Chinese, as the source spells it |
| `viewCount` | View count at scrape time |
| `likeCount` | Like count at scrape time |
| `favoriteCount` | Favourite count at scrape time |
| `coinCount` | Coin count at scrape time, `null` when the endpoint omits it |
| `danmakuCount` | Number of danmaku the source declares for the video |
| `commentCount` | Number of comments the source declares for the video |
| `tags` | Tag list exactly as the video page carries it |
| `ownerMid` | Numeric creator id |
| `ownerName` | Creator display name |
| `pages` | Part list for a multi-part video, `null` for a single-part video |
| `target` | The keyword, video or creator id the row came from |
| `searchOrder` | Sort order that produced the row in search mode |
| `searchRank` | Position of the video inside that sort order |
| `rpid` | Comment id |
| `rootRpid` | Root comment id a reply belongs to |
| `message` | Comment text |
| `replyCount` | Replies the source declares under a root comment |
| `offsetSeconds` | Position of a danmaku on the video timeline, in seconds |
| `mode` | Danmaku render mode as a number |
| `color` | Danmaku colour as a number |

Fields the current mode does not fill are `null`, never invented and never dropped. Output is available as JSON, CSV or Excel.

```json
{
  "resultId": "bilibili:video:BV1ug4y1t7Ty",
  "kind": "search",
  "status": "ok",
  "reason": null,
  "bvid": "BV1ug4y1t7Ty",
  "aid": 823643366,
  "title": "【整整600集】清华大学196小时讲完的AI人工智能从入门到精通全套教程，全程干货无废话！...",
  "url": "https://www.bilibili.com/video/BV1ug4y1t7Ty",
  "durationSeconds": 217142,
  "publishedAt": "2023-03-18T08:08:31.000Z",
  "tid": 231,
  "tname": "计算机技术",
  "viewCount": 828248,
  "likeCount": 19924,
  "favoriteCount": 51372,
  "danmakuCount": 7713,
  "commentCount": 9251,
  "ownerMid": 1741962246,
  "ownerName": "IT界扛霸子",
  "tags": ["人工智能", "计算机", "机器学习", "AI", "科技猎手2023"],
  "target": "人工智能教程",
  "searchOrder": "totalrank",
  "searchRank": 1
}
```

### How to use it

1. Pick `mode`. Search needs keywords, video needs video links, creator needs numeric creator ids.
2. Fill only the inputs your mode reads. The rest stay at their defaults and are ignored.
3. Cap the run with `maxItems` and `runBudgetSecs` so an expensive keyword cannot run away.
4. Start the run and download the dataset as JSON, CSV or Excel.

```json
{
  "mode": "search",
  "queries": ["人工智能教程", "露营"],
  "searchOrders": ["totalrank", "click"],
  "maxItems": 200,
  "maxPagesPerOrder": 3,
  "rowsPerPage": 20,
  "requestDelayMs": 400,
  "requestTimeoutSecs": 25,
  "runBudgetSecs": 300
}
```

| Input | Default | What it does |
|---|---|---|
| `mode` | `search` | Which of the seven modes to run |
| `queries` | `[]` | Keywords, one target per keyword |
| `videoUrls` | `[]` | Video links or bare BV ids |
| `creatorMids` | `[]` | Numeric creator ids |
| `searchOrders` | `["totalrank"]` | Which sort orders to walk and merge |
| `maxItems` | `200` | Hard cap on dataset rows for the whole run |
| `maxPagesPerOrder` | `5` | Page cap per keyword per sort order |
| `rowsPerPage` | `20` | Videos requested per search call |
| `maxCreatorPages` | `40` | Page cap for the creator upload list, 50 videos per page |
| `includeReplies` | `false` | Fetch the replies under each root comment |
| `commentsPerVideo` | `9` | Root comments kept per video |
| `danmakuLimit` | `3000` | Danmaku rows kept per video |
| `requestDelayMs` | `400` | Gap between requests in milliseconds |
| `requestTimeoutSecs` | `25` | Per-request timeout in seconds |
| `runBudgetSecs` | empty | Wall-clock budget, stops requesting when spent |

#### Ready-made tasks

Three saved inputs, one per question this actor answers. Each one shows only the fields it needs, and each returns data on its first run.

| Task | Input | Question it answers |
|---|---|---|
| [Bilibili Keyword Search Scraper](https://apify.com/ai-lead-gen-tools/bilibili-scraper/examples/bilibili-keyword-search) | `mode: search`, `queries`, `searchOrders`, `maxPagesPerOrder` | what exists on a topic, merged over three sort orders so the long tail is not lost |
| [Bilibili Creator Videos](https://apify.com/ai-lead-gen-tools/bilibili-scraper/examples/bilibili-creator-videos) | `mode: creator`, `creatorMids`, `maxCreatorPages` | the upload list behind a channel id, page by page |
| [Bilibili Video Comments](https://apify.com/ai-lead-gen-tools/bilibili-scraper/examples/bilibili-video-comments) | `mode: comments`, `videoUrls`, `commentsPerVideo`, `includeReplies` | root comments under one video with the replies attached |

All three run with `runBudgetSecs` at 205, so they finish before the platform timeout instead of being killed by it.

### Modes

| Mode | What it requests | Rows it leaves |
|---|---|---|
| `search` | Search pages for every keyword and sort order | One row per distinct video, with `searchOrder` and `searchRank` |
| `video` | The view endpoint per video id | One row per video with the full statistic block and the part list |
| `creator` | Creator card plus the upload list, 50 per page | One creator row plus one row per uploaded video |
| `popular` | The popular feed, paged | One row per video on the feed |
| `ranking` | The ranking board | One row per ranked video |
| `comments` | Comment endpoints per video | One row per root comment, plus replies when enabled |
| `danmaku` | The danmaku file per part | One row per bullet comment inside the cap |

### Use cases

- Social listening across Chinese video - track how a product, a game or a topic is covered by Bilibili creators, with view and like counts to rank the videos that matter.
- Creator prospecting - pull a channel's whole upload list with view counts per video and decide on a sponsorship without opening the site.
- Dataset building for research - collect titles, tags, categories and durations into a table you can join with your own data.
- Comment and danmaku mining - read what viewers say about a specific video, bounded by the window and the caps the source really applies.

### Cost

**$0.02 per 1 000 rows.** The Store adds a 20 % Apify margin on top of that price, and the buyer sees the margin in the invoice, not in this number.

You pay per row the actor actually pushed into the default dataset, on top of the usual Apify platform costs:

- `video-scraped` - one video row, from search, video, popular, ranking or creator mode.
- `creator-scraped` - one creator profile row.
- `comment-scraped` - one comment or reply row.
- `danmaku-scraped` - one danmaku row.
- `apify-actor-start` - charged once per run, the first five seconds of compute are not billed.

Nothing else is charged. A diagnostic row for a target that returned nothing is priced at the same per row rate as a real row, so a bad keyword cannot produce free traffic. Requests that return an error are retried and cost nothing extra.

### Honest limits

- Comments are capped hard by Bilibili: nine distinct root comments per video and at most twenty replies under each, whichever endpoint and sort order is asked. A video declaring 9 251 comments still yields nine roots.
- Danmaku is capped by the server maxlimit and by the four segment pages the endpoint serves. A video declaring 7 713 danmaku cannot be read to the end through this path.
- Subtitles, article bodies, favourites and anime subscriptions are not reachable without a logged-in session and are not advertised here.
- Search depth per sort order plateaus on its own: one order stops at 288 distinct videos, so wide coverage requires the union of several orders and proportionally more requests.
- The actor runs without a proxy. Bilibili answers 412 when requests to the space endpoint come too fast, so `requestDelayMs` must stay above a few hundred milliseconds.
- Fields the source omits stay `null`. `coinCount`, `shareCount` and `score` are commonly absent from the search payload.

### FAQ

**Do I need a Bilibili account or cookies?**
No. Every mode reads endpoints that answer anonymous requests. No account, cookie or API key is used.

**Why does a video with thousands of comments return only nine?**
Because the source serves nine distinct root comments per video regardless of the requested count. The `commentsPerVideo` input above nine changes nothing, and the actor reports the real number.

**Can I read the whole danmaku file of a long video?**
Not through this path. The server enforces a maxlimit and serves only four six-minute segment pages, so a long video loses rows in the middle of the timeline rather than at its end.

**What happens when a keyword returns nothing?**
The run leaves one explicit diagnostic row with `status` and `reason` instead of silence, so an empty dataset never means a broken run.

**Can I resume a run that hit the budget?**
Yes, within the same run only. Rows already pushed are kept, and the summary reports the budget as exhausted. A new run starts from the beginning.

**How do I avoid duplicates between runs?**
Filter on `resultId`. It is stable across runs for the same video, creator, comment or danmaku, so a downstream join removes the overlap.

**Does the actor need a proxy?**
No. Runs complete without one. Very large keyword lists benefit from a longer `requestDelayMs` rather than from a proxy.

**Which mode should I pick for a single video?**
`video` for the statistic block and the part list, `comments` for the thread, `danmaku` for the bullet comments. Combining modes on one target is not supported in one run, except through `search`, which also fills the video fields.

**Is the Chinese category name usable as a filter?**
`tname` and `tid` both come straight from the source, so they join cleanly with a category table of your own, but the actor does not translate them.

### Related actors

- [Bilibili Danmaku Scraper](/bilibili-danmaku-scraper) - reads danmaku alone, with a time window, render mode and pool filters.

### Changelog

- 2026-11-14: card rewritten to the publishing standard, price set to $0.02 per 1 000 rows.
- 2026-11-09: seven modes verified against live Bilibili without a proxy or cookies.

# Actor input Schema

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

What to scrape. `search` reads keyword results, `video` reads the video URLs and BV ids you list, `creator` reads a creator profile and the whole upload list, `popular` reads the popular feed, `ranking` reads the ranking board, `comments` reads root comments for the videos you list, `danmaku` reads danmaku for the videos you list.

## `queries` (type: `array`):

Keywords to search, one target per keyword. Bilibili accepts the keyword as typed, so Chinese terms give the best recall.

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

Full video links or bare BV ids, one target per video. An `av` id or a `/video/` URL is reduced to its BV id before the detail request.

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

Numeric creator ids, one target per creator. The upload list is read at 50 videos per request and followed until the creator's catalogue ends; 683 of 683 on the reference channel.

## `searchOrders` (type: `array`):

Which of the six search orders to walk and merge. One order alone plateaus at 288 distinct videos; all six together give 1144 to 1199 for one keyword. Each order costs its own requests, so the default walks `totalrank` only and the full union is opt-in.

## `maxItems` (type: `integer`):

Hard cap on dataset rows for the whole run, shared across every target. The run stops requesting once the cap is reached.

## `maxPagesPerOrder` (type: `integer`):

Page cap per keyword per sort order, counted in search requests. A target also stops earlier once a page adds no new video, which is what a single order does after roughly fifteen pages.

## `rowsPerPage` (type: `integer`):

Page size requested from search. Bilibili serves 20 per page reliably; page 1 occasionally comes back empty, so the actor retries it once before giving up.

## `maxCreatorPages` (type: `integer`):

Page cap for the creator upload list, 50 videos per page. The default follows the whole catalogue; lower it to sample a large channel.

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

Fetch the replies under each root comment. Bilibili returns at most twenty replies per root no matter which variant is asked, so this adds rows but cannot reach the full thread.

## `commentsPerVideo` (type: `integer`):

How many distinct root comments to keep per video. The source serves nine across every mode and the legacy sort, so a larger number changes nothing.

## `danmakuLimit` (type: `integer`):

Cap on danmaku rows per video. The server enforces its own maxlimit and the segment endpoint serves only four six-minute segments, so a large value does not guarantee more rows.

## `requestDelayMs` (type: `integer`):

Gap between requests, in milliseconds. Bilibili answers 412 when requests to the space endpoint come too fast, so keep this above a few hundred milliseconds.

## `requestTimeoutSecs` (type: `integer`):

Per-request timeout in seconds.

## `runBudgetSecs` (type: `integer`):

Wall-clock budget. The run stops requesting once it is spent and still writes the rows it already collected.

## Actor input object example

```json
{
  "mode": "search",
  "queries": [
    "人工智能教程",
    "露营"
  ],
  "videoUrls": [
    "https://www.bilibili.com/video/BV1ug4y1t7Ty"
  ],
  "creatorMids": [
    "1741962246"
  ],
  "searchOrders": [
    "totalrank"
  ],
  "maxItems": 200,
  "maxPagesPerOrder": 5,
  "rowsPerPage": 20,
  "maxCreatorPages": 40,
  "includeReplies": false,
  "commentsPerVideo": 9,
  "danmakuLimit": 3000,
  "requestDelayMs": 400,
  "requestTimeoutSecs": 25,
  "runBudgetSecs": 205
}
```

# Actor output Schema

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

Video rows with statistics, owner and parts; search rows with the order and rank that produced them; creator rows with follower, like and upload counts; comment rows with the reply ceiling stated in the reason field; danmaku rows with offset, mode, colour and sender hash. Every field is always present — unknown values are null, never omitted — so the column set stays stable between runs and between row kinds.

## `summary` (type: `string`):

Counters for the run: targets requested and completed, requests made, retries, HTTP status distribution, rows by kind, duplicates skipped, the modes and sort orders actually applied, the budget state and how many events were charged.

# 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 = {
    "mode": "search",
    "queries": [
        "人工智能教程",
        "露营"
    ],
    "videoUrls": [
        "https://www.bilibili.com/video/BV1ug4y1t7Ty"
    ],
    "creatorMids": [
        "1741962246"
    ],
    "searchOrders": [
        "totalrank"
    ],
    "runBudgetSecs": 205
};

// Run the Actor and wait for it to finish
const run = await client.actor("ai-lead-gen-tools/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 = {
    "mode": "search",
    "queries": [
        "人工智能教程",
        "露营",
    ],
    "videoUrls": ["https://www.bilibili.com/video/BV1ug4y1t7Ty"],
    "creatorMids": ["1741962246"],
    "searchOrders": ["totalrank"],
    "runBudgetSecs": 205,
}

# Run the Actor and wait for it to finish
run = client.actor("ai-lead-gen-tools/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 '{
  "mode": "search",
  "queries": [
    "人工智能教程",
    "露营"
  ],
  "videoUrls": [
    "https://www.bilibili.com/video/BV1ug4y1t7Ty"
  ],
  "creatorMids": [
    "1741962246"
  ],
  "searchOrders": [
    "totalrank"
  ],
  "runBudgetSecs": 205
}' |
apify call ai-lead-gen-tools/bilibili-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ai-lead-gen-tools/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/rNpzPoNmF9rnut4JA/builds/FGl6jZkrIEkSEdHPP/openapi.json
