# Bilibili Scraper – Videos, Comments, Danmaku & Users (`scrapepilot/bilibili-scraper-videos-comments-danmaku-users`) Actor

Scrape Bilibili videos, comments, danmaku (bullet chats), creator profiles & user archives. 6 modes: search, trending, video detail, comments, user videos, profile. Clean JSON, delta mode, PPE pricing. $17/1K items + $30/1K danmaku.

- **URL**: https://apify.com/scrapepilot/bilibili-scraper-videos-comments-danmaku-users.md
- **Developed by:** [Scrape Pilot](https://apify.com/scrapepilot) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $17.00 / 1,000 bilibili scraped items

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 Pro — Videos, Comments, Danmaku, User Profiles

***

**The most comprehensive Bilibili scraper on Apify.** Extract videos, comments, danmaku (bullet comments), creator profiles, and deep metadata from China's #1 video platform. Search by keyword, fetch trending feeds, scrape entire creator libraries, or dig deep into a single video — all with one powerful actor.

**Pricing:** Pay only for what you use — **$17 per 1,000 items** (videos, comments, users) and **$30 per 1,000 danmaku profiles**. Actor start: **$0.02 per run**.

***

### 💡 What is the Bilibili Scraper Pro?

Bilibili (B站) is the largest video platform in China with over **300 million monthly active users**. This actor is designed to extract structured, actionable data from every corner of the platform — including hard-to-reach data like **danmaku bullet comments** and **creator archive libraries**.

Unlike basic scrapers, this actor uses a real **browser-like session** that warms up cookies (`buvid3`, `b_nut`) to avoid Bilibili's anti-bot protections, plus optional **Apify residential proxies** for large-scale runs. The result is a reliable, production-grade Bilibili data pipeline.

**Six powerful scraping modes in one actor:**

1. **Search Mode** — Search videos by keyword with sorting, duration, and category filters.
2. **Popular Mode** — Scrape Bilibili's trending/popular video feed.
3. **Video Detail Mode** — Extract complete metadata for specific videos (by URL or BVID).
4. **Video Comments Mode** — Scrape comments for one or more videos, with optional replies.
5. **User Videos Mode** — Fetch every video from a creator's archive (plus their profile).
6. **User Profile Mode** — Get complete creator cards: fans, level, official status, etc.

***

### 🚀 Key Features

| Feature | Description |
|---------|-------------|
| **6 Scrape Modes** | Search, Popular, Video Detail, Video Comments, User Videos, User Profile. |
| **Danmaku Reaction Profiles** | Parse bullet comments to get sender counts, per-minute rate, peak minute, timeline sample. |
| **Nested Comments** | Fetch top-level comments and (optionally) their replies in one call. |
| **Creator Cards** | Get fans, level, official status, archive count, total likes, and more. |
| **Delta Mode** | Save processed BVIDs to KV store so subsequent runs only return new items. |
| **Cookie Warming** | Realistic Chrome 124 fingerprint + tracking cookie handshake to bypass 412. |
| **HTML Deep Parsing** | Extracts `window.__INITIAL_STATE__` from video pages for complete metadata. |
| **Residential Proxy Ready** | Compatible with Apify residential proxies for high-volume production runs. |
| **Pay-Per-Event Pricing** | $17/1K items, $30/1K danmaku profiles, $0.02 actor start — transparent. |
| **Clean JSON Output** | Consistent schema across all modes; ready for analytics or ML pipelines. |

***

### 📥 Input Parameters

The actor accepts a JSON object with the following fields. **Which fields are required depends on the `mode`.**

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `mode` | string | Yes | `"search"` | `search`, `popular`, `video_detail`, `video_comments`, `user_videos`, or `user_profile`. |
| `searchQuery` | string | Search mode | `"人工智能教程"` | Keyword for search mode. |
| `videoUrls` | array | Video modes | `["https://www.bilibili.com/video/BV1bmTb6EEs8"]` | Video URLs or BVIDs for detail/comment modes. |
| `userUrls` | array | User modes | `["https://space.bilibili.com/546195"]` | Creator space URLs or MIDs. |
| `maxResults` | integer | No | `50` | Max videos to return (search/popular/user_videos). |
| `sortOrder` | string | No | `"totalrank"` | Search sort: `totalrank`, `click`, `pubdate`, `dm`, `stow`. |
| `durationFilter` | string | No | `"any"` | `any`, `short` (<10m), `medium` (10–30m), `long` (30–60m), `huge` (>60m). |
| `category` | string | No | `"all"` | Numeric category ID or `"all"`. |
| `includeComments` | boolean | No | `false` | Also fetch comments for each video. |
| `maxComments` | integer | No | `20` | Max comments per video. |
| `sortComments` | string | No | `"hot"` | `hot` or `time`. |
| `includeReplies` | boolean | Video-comments mode | `false` | Fetch nested replies too. |
| `includeDanmaku` | boolean | No | `false` | Include danmaku reaction profile for each video. |
| `danmakuSampleSize` | integer | No | `25` | Number of danmaku items in the timeline sample. |
| `deltaMode` | boolean | No | `false` | Only return items not seen in previous runs. |
| `deltaStateKey` | string | No | `"default"` | Separate delta state for different pipelines. |
| `proxyConfiguration` | object | No | – | Apify proxy config (residential strongly recommended for large runs). |

#### Example Input — Search Mode

```json
{
  "mode": "search",
  "searchQuery": "人工智能教程",
  "maxResults": 20,
  "sortOrder": "click",
  "durationFilter": "medium",
  "includeComments": true,
  "maxComments": 10,
  "includeDanmaku": true
}
```

#### Example Input — Video Detail Mode

```json
{
  "mode": "video_detail",
  "videoUrls": [
    "https://www.bilibili.com/video/BV1bmTb6EEs8",
    "BV1qZSLBYEpa"
  ],
  "includeComments": true,
  "maxComments": 30,
  "includeDanmaku": true,
  "danmakuSampleSize": 50
}
```

#### Example Input — User Videos Mode

```json
{
  "mode": "user_videos",
  "userUrls": ["https://space.bilibili.com/546195"],
  "maxResults": 50,
  "includeComments": false
}
```

***

### 📤 Output Fields

The actor outputs **multiple record types** depending on mode:

#### 1. `type: "video"` — Video Record

| Field | Type | Description |
|-------|------|-------------|
| `bvid` | string | Bilibili video ID (BV…). |
| `aid` | integer | Numeric archive ID. |
| `title` | string | Video title (HTML cleaned). |
| `description` | string | Video description. |
| `url` | string | Canonical video URL. |
| `thumbnailUrl` | string | Thumbnail URL (https-normalized). |
| `duration` | integer | Duration in seconds. |
| `durationFormatted` | string | Duration as `mm:ss` or `h:mm:ss`. |
| `viewCount` | integer | Total views. |
| `likeCount` | integer | Total likes. |
| `coinCount` | integer | Bilibili coins. |
| `favoriteCount` | integer | Favorites. |
| `shareCount` | integer | Shares. |
| `danmakuCount` | integer | Total danmaku. |
| `replyCount` | integer | Total comments. |
| `authorName` | string | Uploader display name. |
| `authorMid` | integer | Uploader numeric ID. |
| `publishDate` | string | ISO 8601 publish date. |
| `publishTimestamp` | integer | Unix epoch. |
| `category` | string | Video category name. |
| `tags` | array | Video tags. |
| `scrapedAt` | string | ISO 8601 extraction time. |

#### 2. `type: "comment"` — Comment Record

| Field | Type | Description |
|-------|------|-------------|
| `commentId` | integer | Bilibili reply ID. |
| `text` | string | Comment text. |
| `likeCount` | integer | Likes on the comment. |
| `replyCount` | integer | Replies to this comment. |
| `createdAt` | string | ISO 8601 time. |
| `createdTimestamp` | integer | Unix epoch. |
| `authorName` | string | Commenter name. |
| `authorMid` | integer | Commenter numeric ID. |
| `authorAvatar` | string | Avatar URL. |
| `authorLevel` | integer | Bilibili user level (0–6). |
| `videoBvid` | string | Source video BVID. |
| `scrapedAt` | string | ISO 8601 extraction time. |

#### 3. `type: "danmaku_profile"` — Danmaku Reaction Profile

| Field | Type | Description |
|-------|------|-------------|
| `videoBvid` | string | Video BVID. |
| `aid` | integer | Video AID. |
| `countFetched` | integer | Danmaku fetched from XML. |
| `totalVideoDanmaku` | integer | Total danmaku count from video metadata. |
| `uniqueSenders` | integer | Distinct sender hashes. |
| `perMinuteRate` | float | Danmaku per minute. |
| `peakMinute` | object | `{minute, danmakuCount}` at peak. |
| `timelineSample` | array | Sampled danmaku across the timeline: `{time, timeFormatted, text, senderHash, timestamp}`. |
| `scrapedAt` | string | ISO 8601 extraction time. |

#### 4. `type: "user"` — Creator Profile

| Field | Type | Description |
|-------|------|-------------|
| `mid` | integer | Creator numeric ID. |
| `name` | string | Display name. |
| `face` | string | Avatar URL. |
| `sign` | string | Bio. |
| `level` | integer | Bilibili level (0–6). |
| `fans` | integer | Follower count. |
| `friend` | integer | Following count. |
| `attention` | integer | Accounts this creator follows. |
| `isOfficial` | boolean | Official verification. |
| `officialDesc` | string | Official status description. |
| `archiveCount` | integer | Total uploaded videos. |
| `likeCount` | integer | Total likes received. |
| `profileUrl` | string | Space URL. |
| `scrapedAt` | string | ISO 8601 extraction time. |

#### Example Output — Search Mode

```json
[
  {
    "type": "video",
    "bvid": "BV1qZSLBYEpa",
    "title": "【整整600集】清华大学196小时讲完的AI人工智能从入门到精通全套教程...",
    "viewCount": 1107723,
    "likeCount": 24014,
    "danmakuCount": 8285,
    "replyCount": 14643,
    "authorName": "IT界扛霸子",
    "url": "https://www.bilibili.com/video/BV1qZSLBYEpa",
    "duration": 0,
    "durationFormatted": "0:00",
    "publishDate": "2026-01-15T08:00:00+00:00",
    "scrapedAt": "2026-10-09T12:00:00+00:00"
  }
]
```

#### Example Output — Danmaku Profile

```json
[
  {
    "type": "danmaku_profile",
    "videoBvid": "BV1qZSLBYEpa",
    "aid": 113456789,
    "countFetched": 3000,
    "totalVideoDanmaku": 8285,
    "uniqueSenders": 2104,
    "perMinuteRate": 42.5,
    "peakMinute": {"minute": 18, "danmakuCount": 312},
    "timelineSample": [
      {"time": 5.4, "timeFormatted": "0:05", "text": "666", "senderHash": "a1b2c3d4", "timestamp": 1768460400}
    ],
    "scrapedAt": "2026-10-09T12:00:05+00:00"
  }
]
```

***

### 💰 Pricing

| Event | Price | Unit |
|-------|-------|------|
| **`item-scraped`** | **$17.00 per 1,000** | Videos, comments, user profiles |
| **`danmaku-profile`** | **$30.00 per 1,000** | Danmaku reaction profile |
| **`apify-actor-start`** | **$0.02 per run** | Startup fee |

**Example costs:**

- **100 videos** with comments: 100 videos + 20 comments each (2,000 comments) = **$17.00** (2,000 items @ $17/1K) + $0.02 = **~$17.02**.
- **50 videos** with danmaku profiles: 50 videos + 50 danmaku profiles = 50 × $0.017 + 50 × $0.030 = **$0.85 + $1.50 = $2.35**.
- **1 user + 500 videos** (user_videos mode): 501 items = **~$8.54**.

***

### 🛠 How to Use on Apify

1. **Create a task** with this actor.
2. **Choose the mode** in the input JSON.
3. **Provide the required URLs / keywords**.
4. **(Optional) Enable residential proxies** for large-scale runs.
5. **Run** – the actor scrapes everything and pushes results to the Dataset.
6. **Export** – download as JSON, CSV, or Excel.

#### Running via API

```bash
curl -X POST "https://api.apify.com/v2/acts/your-username~bilibili-scraper/runs" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{
    "mode": "search",
    "searchQuery": "AI教程",
    "maxResults": 20
  }'
```

***

### 🎯 Use Cases

- **Trending video tracking** – Monitor what content is rising on Bilibili.
- **Content research** – Analyze creator libraries at scale.
- **Danmaku sentiment analysis** – Use bullet comment timelines to find viral moments.
- **Comment analytics** – Study viewer reactions across videos.
- **Creator intelligence** – Build a database of creator stats (fans, level, uploads).
- **Delta monitoring** – Track new uploads from your favorite creators on a schedule.

***

### ❓ Frequently Asked Questions

**1. Do I need a Bilibili account?**\
No. All data is public. No login or cookie supplied by you.

**2. What's the difference between danmaku and comments?**\
**Danmaku** are bullet comments overlaid on the video at specific timestamps. **Comments** are the traditional threaded replies below the video.

**3. Why is `duration` 0 in some search results?**\
Bilibili's search API occasionally omits duration. Use `video_detail` mode on those BVIDs for exact duration.

**4. How does delta mode work?**\
Each processed BVID is saved in the actor's key-value store. On subsequent runs with the same `deltaStateKey`, already-seen items are skipped. Perfect for scheduled daily monitoring.

**5. Do I need a proxy?**\
Not for small runs. For 500+ items per run, use Apify residential proxies to avoid 412 rate-limits.

**6. Why does my danmaku count differ from the video's danmakuCount?**\
Bilibili's XML feed only returns a subset (~3,000) of the total danmaku. `countFetched` reports the number fetched, while `totalVideoDanmaku` reports Bilibili's public count.

**7. Can I scrape playlists or合集?**\
Not in this version. You can scrape all videos from a creator's archive with `user_videos` mode.

**8. Does the actor work outside Apify?**\
Yes — it's a standalone Python script using `apify` SDK. You can run it locally with the Apify CLI.

**9. What happens if I hit the spending limit?**\
The actor detects `event_charge_limit_reached` and exits gracefully, saving all data pushed so far.

**10. Can I run search + comments + danmaku in one go?**\
Yes — combine `mode: "search"`, `includeComments: true`, and `includeDanmaku: true`.

***

***

### 🔍 SEO Keywords

`Bilibili scraper`, `B站 scraper`, `bilibili video scraper`, `bilibili comments`, `bilibili danmaku`, `bilibili bullet comments`, `bilibili user profile scraper`, `bilibili search API`, `bilibili trending videos`, `Apify bilibili actor`, `bilibili delta scraper`, `bilibili creator analytics`

***

### 🔗 Related Actors

- **[YouTube Metadata Scraper](https://apify.com/your-username/youtube-metadata-scraper)** — Full YouTube metadata + formats.
- **[TikTok Video Downloader](https://apify.com/your-username/tiktok-video-downloader)** — Download TikTok videos without watermark.
- **[Instagram Reels Downloader](https://apify.com/your-username/instagram-reels-downloader)** — Reels + captions + likes.

***

***

**Start scraping Bilibili today — $17/1K items, $30/1K danmaku profiles, $0.02 actor start.**

````



# Actor input Schema

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

Choose the scraping mode depending on what data you need from Bilibili.
## `searchQuery` (type: `string`):

Keyword to search for on Bilibili (used in 'search' mode). Example: '人工智能教程'.
## `videoUrls` (type: `array`):

List of Bilibili video URLs or BVIDs (e.g. 'https://www.bilibili.com/video/BV1bmTb6EEs8' or 'BV1qZSLBYEpa'). Used in 'video_detail' and 'video_comments' modes.
## `userUrls` (type: `array`):

List of creator Space URLs or MIDs (e.g. 'https://space.bilibili.com/546195' or '546195'). Used in 'user_videos' and 'user_profile' modes.
## `maxResults` (type: `integer`):

Maximum number of items (videos or creators) to return.
## `sortOrder` (type: `string`):

Sorting criteria for search results.
## `durationFilter` (type: `string`):

Filter search results by video duration length.
## `category` (type: `string`):

Filter by Bilibili category or 'all'.
## `includeComments` (type: `boolean`):

When scraping videos, also extract top comments for each video.
## `maxComments` (type: `integer`):

Maximum number of comments to extract per video.
## `sortComments` (type: `string`):

Order to sort comments.
## `includeReplies` (type: `boolean`):

Whether to extract nested sub-replies to top-level comments.
## `includeDanmaku` (type: `boolean`):

Extract full video danmaku pool and generate a deep reaction profile (charges $0.050 per danmaku profile).
## `danmakuSampleSize` (type: `integer`):

Number of sample danmaku items to include in the reaction profile timeline.
## `autoLocalize` (type: `boolean`):

Automatically formats timestamps to ISO-8601 UTC and seconds to human-readable M:SS / H:MM:SS format.
## `sentimentAnalysis` (type: `boolean`):

Enable sentiment categorization for comments.
## `deltaMode` (type: `boolean`):

Skip items previously seen in prior runs.
## `deltaStateKey` (type: `string`):

Key identifier used to store delta state in Key-Value store.
## `proxyConfiguration` (type: `object`):

Optional proxy settings for large-scale crawling. Apify proxies or custom proxies can be configured.

## Actor input object example

```json
{
  "mode": "search",
  "searchQuery": "人工智能教程",
  "videoUrls": [
    "https://www.bilibili.com/video/BV1bmTb6EEs8"
  ],
  "userUrls": [
    "https://space.bilibili.com/546195"
  ],
  "maxResults": 50,
  "sortOrder": "totalrank",
  "durationFilter": "any",
  "category": "all",
  "includeComments": false,
  "maxComments": 20,
  "sortComments": "hot",
  "includeReplies": false,
  "includeDanmaku": false,
  "danmakuSampleSize": 25,
  "autoLocalize": true,
  "sentimentAnalysis": false,
  "deltaMode": false,
  "deltaStateKey": "default"
}
````

# Actor output Schema

## `results` (type: `string`):

Collection of extracted videos, engagement stats, comments, creator profiles, and danmaku reaction profiles.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapepilot/bilibili-scraper-videos-comments-danmaku-users").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("scrapepilot/bilibili-scraper-videos-comments-danmaku-users").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 '{}' |
apify call scrapepilot/bilibili-scraper-videos-comments-danmaku-users --silent --output-dataset

```

## MCP server setup

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

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/MTwT9uNkY4v31XMo3/builds/jIuTG98zZluIkUMLa/openapi.json
