# Bilibili Scraper 哔哩哔哩 — Search, Videos, Danmaku & Rankings (`china-data/bilibili-scraper`) Actor

Scrape Bilibili (B站) without login: keyword search, video stats and tags, full danmaku (bullet comments), all videos of an uploader (UP主), popular and ranking lists. $2 per 1,000 videos, $0.10 per 1,000 danmaku.

- **URL**: https://apify.com/china-data/bilibili-scraper.md
- **Developed by:** [China Data](https://apify.com/china-data) (community)
- **Categories:** Social media, Videos, Marketing
- **Security:** 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 videos

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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 哔哩哔哩 — Search, Videos, Danmaku & Rankings

Scrape public data from [Bilibili](https://www.bilibili.com) (B站), China's biggest video community, **without logging in and without cookies**.

- 🔎 **Keyword search**: up to 1,000 videos per keyword, with the same sort and length filters as the Bilibili search page.
- 🎬 **Video details**: views, likes, coins (投币), favorites, shares, danmaku count, comment count, tags, parts (分P), description, cover, uploader.
- 💬 **Danmaku (弹幕, bullet comments)**: text, time in the video, sent time, position and colour. The actor merges Bilibili's XML pool with the per-segment feed, so you get more danmaku per video than from the XML file alone.
- 👤 **Uploader (UP主) videos**: all videos of a channel, newest first, plus the uploader's follower count.
- 🔥 **Popular (综合热门)** and **ranking lists (排行榜)**: the whole site or any of 14 categories, the same lists as bilibili.com/v/popular/rank.

Typical uses: tracking trends and competitors in China, influencer research, sentiment analysis of danmaku, building datasets for AI/LLM training and research.

### How to use

1. Add one or more of: search keywords, video URLs, uploader IDs, popular, ranking lists.
2. Optionally turn on **Full video details** and/or **Danmaku**.
3. Click **Start**, then download the results as JSON, CSV, Excel or via the API.

#### Input examples

Search, most viewed first:

```json
{
    "searchQueries": ["原神", "machine learning"],
    "maxResultsPerQuery": 200,
    "searchOrder": "click"
}
```

Danmaku of specific videos (`b23.tv` short links, BV IDs and `av` numbers also work):

```json
{
    "videoUrls": ["https://www.bilibili.com/video/BV1dAxE6VErW"],
    "includeDanmaku": true,
    "maxDanmakuPerVideo": 5000
}
```

All videos of two uploaders, plus today's popular list and the gaming ranking:

```json
{
    "userIds": ["https://space.bilibili.com/401742377", "546195"],
    "maxVideosPerUser": 500,
    "popular": true,
    "rankingCategories": ["1008"]
}
```

### Output

Each video is one row with `"type": "video"`. Danmaku are separate rows with `"type": "danmaku"` and the `bvid` of their video, so CSV and Excel exports stay flat. The **Videos** and **Danmaku** tabs of the dataset show each kind as a table.

Video row (from a real run, description shortened):

```json
{
    "type": "video",
    "bvid": "BV1dAxE6VErW",
    "aid": 117518106630700,
    "url": "https://www.bilibili.com/video/BV1dAxE6VErW",
    "title": "《原神》米提亚角色PV——「小小伎俩」",
    "description": "在劫后余生后的某个清晨，米提亚决定逃避监督，并趁机给忙碌的朋友们带些礼物。…",
    "coverUrl": "https://i1.hdslb.com/bfs/archive/1ce0d6e289e89c0c5740b9d9434f0dc40b1cc399.jpg",
    "durationSec": 677,
    "publishedAt": "2026-10-29T04:00:00Z",
    "category": null,
    "uploaderMid": 401742377,
    "uploaderName": "原神",
    "uploaderFollowers": null,
    "views": 1582382,
    "likes": 232744,
    "coins": 65373,
    "favorites": 47065,
    "shares": 18310,
    "danmakuCount": 18929,
    "commentCount": 12501,
    "tags": ["米提亚", "米哈游", "miHoYo", "原神"],
    "partsCount": 4,
    "parts": [
        { "cid": 43125246260, "page": 1, "title": "《原神》米提亚角色PV——「小小伎俩」", "durationSec": 167 },
        { "cid": 43125310951, "page": 2, "title": "日-《原神》米提亚角色PV——「小小伎俩」", "durationSec": 170 }
    ],
    "source": "url",
    "rank": null,
    "scrapedAt": "2026-11-01T19:11:45Z"
}
```

Danmaku row:

```json
{
    "type": "danmaku",
    "bvid": "BV1dAxE6VErW",
    "cid": 43125246260,
    "part": 1,
    "dmid": "2232672416008769792",
    "text": "在劫后余生后的某个清晨，米提亚决定逃避监督，并趁机给忙碌的朋友们带些礼物。",
    "timeInVideoSec": 0.0,
    "sentAt": "2026-10-29T04:01:32Z",
    "position": "top",
    "mode": 5,
    "fontSize": 18,
    "color": "#ffffff"
}
```

`source` tells you where a video came from (`search:<keyword>`, `user:<mid>`, `popular`, `ranking:<category>` or `url`) and `rank` is its position there.

Which fields are filled depends on the source:

| Field | Search | Uploader | Popular / ranking | Video URL or "Full video details" |
|---|---|---|---|---|
| views, title, cover, length, date | ✅ | ✅ | ✅ | ✅ |
| likes, favorites, danmaku and comment counts | ✅ | — | ✅ | ✅ |
| coins, shares | — | — | ✅ | ✅ |
| tags | ✅ | — | — | ✅ |
| parts (分P) | — | — | — | ✅ |
| uploader followers | — | ✅ | — | — |

### Pricing

Pay only for what you get — no monthly rental:

| What | Price |
|---|---|
| Video | **$2.00 per 1,000 videos** ($0.002 each) |
| Danmaku | **$0.10 per 1,000 danmaku** ($0.0001 each) |

Set a maximum cost per run in the run options; the actor stops cleanly when it is reached and keeps everything scraped so far.

### Tips and limits

- **Speed**: about 10 videos per second for search, uploader, popular and ranking lists. "Full video details" and danmaku need extra requests per video, so they are slower.
- **Search** returns at most 1,000 results per keyword (Bilibili's own limit). Use several keywords or sort orders to get more.
- **Danmaku**: Bilibili does not publish every danmaku ever sent on very popular videos; the actor returns everything Bilibili serves for each part (分P), de-duplicated.
- **Comments (评论)** are not included: Bilibili shows visitors who are not logged in only the first 3 comments of a video.
- **Category** is empty for videos from uploader lists and video URLs, because Bilibili no longer returns it there; search, popular and ranking results include it.
- **Proxy**: not needed for normal runs. If Bilibili blocks a very large run, turn on Apify Proxy in the input.

### 中文说明

免登录、免 Cookie 采集 B站公开数据：关键词搜索（最多 1000 条/词）、视频详情（播放、点赞、投币、收藏、分享、弹幕数、评论数、标签、分P）、完整弹幕（XML 弹幕池 + 分段弹幕合并去重）、UP主全部投稿和粉丝数、综合热门、全站及 14 个分区排行榜。按条计费：视频 $2/千条，弹幕 $0.1/千条，可设置单次运行费用上限。

### Is it legal?

The actor only collects data that Bilibili shows publicly to visitors who are not logged in. It does not collect personal data about viewers: danmaku are saved without any sender ID. Make sure your use of the data complies with the laws that apply to you and with Bilibili's terms.

# Actor input Schema

## `searchQueries` (type: `array`):

Keywords to search Bilibili videos for, in any language. Each keyword returns up to 'Max results per keyword' videos.

## `maxResultsPerQuery` (type: `integer`):

Bilibili shows at most 1,000 results per keyword.

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

Same options as the Bilibili search page.

## `searchDuration` (type: `string`):

Only return videos of this length.

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

Full details for specific videos. Accepts bilibili.com/video/BV… links, b23.tv short links, BV IDs and av numbers.

## `userIds` (type: `array`):

Get the videos of these uploaders, newest first. Accepts numeric user IDs (mid) or space.bilibili.com/… links.

## `maxVideosPerUser` (type: `integer`):

Newest videos are returned first.

## `popular` (type: `boolean`):

Get the current list of popular videos.

## `maxPopular` (type: `integer`):

The popular list has up to about 1,000 videos.

## `rankingCategories` (type: `array`):

Get the current top-100 of these ranking lists (same categories as bilibili.com/v/popular/rank).

## `maxPerRanking` (type: `integer`):

Rankings have up to 100 videos.

## `includeDetails` (type: `boolean`):

Add coins, shares, tags, parts (分P) and the full description to videos from search, uploaders, popular and rankings. Uses two extra requests per video, so runs are slower. Videos from 'Video URLs' always have full details.

## `includeDanmaku` (type: `boolean`):

Save the danmaku of every scraped video as separate rows (type = danmaku), with the time in the video, text, sent time, position and colour.

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

Danmaku are charged per row, so this also caps the cost per video.

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

Not needed for most runs. Turn on Apify Proxy if Bilibili starts blocking requests on very large runs.

## Actor input object example

```json
{
  "searchQueries": [
    "原神"
  ],
  "maxResultsPerQuery": 20,
  "searchOrder": "totalrank",
  "searchDuration": "0",
  "maxVideosPerUser": 100,
  "popular": false,
  "maxPopular": 100,
  "maxPerRanking": 100,
  "includeDetails": false,
  "includeDanmaku": false,
  "maxDanmakuPerVideo": 1000,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

All results are saved to the default dataset. Each item has `type`: `video` (stats, tags, uploader) or `danmaku` (one bullet comment, linked by `bvid`).

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

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

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,china-data/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/hr0ibFei9qndKGqCc/builds/gqUzrYzdwFdDI6chS/openapi.json
