# Bilibili Scraper – Videos, Search, Rankings, Comments & Danmaku (`openharvest/bilibili-scraper`) Actor

Bilibili scraper for public data, no login: popular and ranking (排行榜) videos, keyword search, video details with views, likes, coins and favorites, comments, danmaku (弹幕 bullet comments) and uploader search. Pay per result.

- **URL**: https://apify.com/openharvest/bilibili-scraper.md
- **Developed by:** [Enes Bulanık](https://apify.com/openharvest) (community)
- **Categories:** Social media, Videos, AI
- **Stats:** 3 total users, 2 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 – Videos, Search, Rankings, Comments & Danmaku

Bilibili scraper for public data, no login: popular (热门) and ranking (排行榜) videos, keyword search, video details with views, likes, coins and favorites, comments, danmaku (弹幕 bullet comments) and uploader (UP主) search. Use it instead of a general web crawler when you need clean Bilibili JSON with every mode in one Actor at **$2 per 1,000 videos**.

### What data do you get?

- 🎬 **Videos** – BV id, av id, title, description, cover, duration, publish date, category, tags, uploader name and id, and statistics: views, likes, coins, favorites, shares, danmaku count and comment count
- 🔥 **Popular list** – Bilibili's current 热门 feed (up to ~500 videos) with the recommendation reason (e.g. "百万播放")
- 🏆 **Rankings** – top-100 排行榜 for all of Bilibili or one zone (gaming, music, tech, knowledge, food, dance…), overall / original / rookie
- 🔎 **Search** – videos for any Chinese or English keyword, sorted by relevance, views, newest, danmaku or favorites (up to 1,000 per keyword)
- 💬 **Comments** – pinned and hot comments plus their replies: text, likes, reply count, date, whether the uploader wrote it
- 📜 **Danmaku** – bullet comments with the exact video timestamp, text, display mode (scroll / top / bottom), color and send date
- 👤 **Uploaders** – UP主 search: name, UID, followers, number of videos, level, verification and latest videos

All items are flat JSON with consistent field names. Export as JSON, CSV, Excel, XML or HTML, or use the Apify API.

### Use cases

- **Trend & content research** – what is hot in China right now, per category, every day.
- **Brand and game monitoring** – track videos and audience reactions for your game, product or brand keyword.
- **Influencer (KOL) discovery** – find UP主 by topic and compare followers and engagement (coins, favorites, likes per view).
- **Audience sentiment & NLP** – danmaku and comments are a uniquely rich, time-coded reaction dataset for sentiment analysis and LLM training/evaluation.
- **Market entry for China** – understand which formats, topics and creators win on Bilibili before you invest.

### How to use

1. Pick **What to scrape**: Popular, Ranking, Search, Specific videos or Search uploaders.
2. Fill in keywords (search modes) or video links / BV ids (videos mode).
3. Optionally switch on **Include comments** and/or **Include danmaku**.
4. Click **Start**. The default input (`{}` = 20 popular videos) finishes in about 15 seconds.

### Input example

```json
{
    "mode": "search",
    "searchQueries": ["原神"],
    "searchOrder": "totalrank",
    "maxItems": 5,
    "includeComments": true,
    "maxCommentsPerVideo": 100,
    "includeDanmaku": true,
    "maxDanmakuPerVideo": 0
}
```

| Field | Type | Description |
|---|---|---|
| `mode` | enum | `popular` (default), `ranking`, `search`, `videos`, `searchUploaders` |
| `searchQueries` | array | Keywords for `search` / `searchUploaders` |
| `videoUrls` | array | Video links, `BV…` ids or `av…` numbers for `videos` |
| `rankingCategory` | enum | Zone id for `ranking` (`0` = all, `4` = gaming, `188` = tech, …) |
| `rankingType` | enum | `all`, `origin`, `rookie` |
| `searchOrder` | enum | `totalrank`, `click`, `pubdate`, `dm`, `stow` |
| `maxItems` | integer | Max videos (or uploaders) per run / per keyword. Default `20` |
| `includeTags` | boolean | Load each video's tag list (free) |
| `includeComments` / `maxCommentsPerVideo` | boolean / integer | Comments per video (default 20) |
| `includeDanmaku` / `maxDanmakuPerVideo` | boolean / integer | Danmaku per video (default 200, `0` = all) |
| `proxyConfiguration` | object | Optional proxy (see FAQ) |

### Output sample

Real items from a run on 2026-10-08 (shortened):

```json
{
    "type": "video",
    "source": "search",
    "rank": 1,
    "searchQuery": "原神",
    "bvid": "BV1F8aJ6TEKz",
    "aid": "117353505429329",
    "cid": "42304735801",
    "url": "https://www.bilibili.com/video/BV1F8aJ6TEKz",
    "title": "《原神》剧情PV-「往日」",
    "coverUrl": "https://i1.hdslb.com/bfs/archive/489850205a82aba0b3c246f69b124fdc6cfe35d3.jpg",
    "durationSec": 1402,
    "publishedAt": "2026-10-07T04:00:00.000Z",
    "category": "手机游戏",
    "tags": ["原神", "miHoYo", "米哈游"],
    "uploaderName": "原神",
    "uploaderId": "401742377",
    "uploaderUrl": "https://space.bilibili.com/401742377",
    "views": 495644,
    "likes": 67441,
    "coins": 11878,
    "favorites": 9550,
    "shares": 2959,
    "danmakuCount": 4861,
    "commentCount": 9237,
    "partsCount": 4
}
```

```json
{
    "type": "comment",
    "bvid": "BV1F8aJ6TEKz",
    "commentId": "316322760481",
    "rootCommentId": null,
    "isReply": false,
    "isPinned": false,
    "isByUploader": false,
    "text": "海包海包帮我生成停止圣土化的方法",
    "likes": 3861,
    "replyCount": 18,
    "postedAt": "2026-10-07T04:10:23.000Z"
}
```

```json
{
    "type": "danmaku",
    "bvid": "BV1F8aJ6TEKz",
    "cid": "42304735801",
    "danmakuId": "2216727619263765248",
    "videoTimeSec": 0,
    "text": "往日种种…",
    "mode": "top",
    "fontSize": 25,
    "color": "#ffffff",
    "sentAt": "2026-10-07T04:02:04.000Z"
}
```

Other item types: `uploader` (uploaderId, uploaderName, followers, videosCount, level, verified, latestVideos) and `error` (free – `errorCode` is `INVALID_INPUT`, `NOT_FOUND`, `NO_RESULTS`, `BLOCKED`, `NO_CID` or `SCRAPE_FAILED`). The dataset has views: **Overview**, **Comments**, **Danmaku**, **Uploaders & errors**.

### Pricing

Pay per event – you pay only for results. Error rows are free.

| Event | Price | Per 1,000 |
|---|---|---|
| `video` – one video row | $0.002 | $2.00 |
| `comment` – one comment | $0.001 | $1.00 |
| `danmaku` – one bullet comment | $0.0005 | $0.50 |
| `uploader` – one uploader (UP主) row | $0.002 | $2.00 |

Examples: 100 ranking videos = **$0.20**. 5 search videos + 194 comments + 2,030 danmaku (real run above) = $0.01 + $0.194 + $1.015 = **$1.22**. Set *Max cost per run* in the run options – the Actor stops cleanly at your budget and never pushes unpaid items.

### Use with AI agents (MCP)

The Actor works as a tool in Apify's MCP server, so Claude, Cursor and other MCP clients can call it. Add the Actor in your MCP client by its Store name and send input like:

```json
{
    "mode": "ranking",
    "rankingCategory": "188",
    "maxItems": 10,
    "includeTags": true
}
```

The agent gets back flat rows with `title`, `views`, `likes`, `coins`, `favorites`, `tags` and `url`. Keep `maxItems`, `maxCommentsPerVideo` and `maxDanmakuPerVideo` small in agent loops – danmaku can be thousands of rows per video.

### FAQ

**Do I need a Bilibili account or cookies?**
No. The Actor uses the same public endpoints a logged-out visitor's browser uses, with anonymous visitor cookies and Bilibili's WBI request signing handled for you.

**Why do I get only 20–70 comments per video?**
Bilibili shows logged-out visitors only the pinned and top hot comments and the first page of replies under each. The Actor collects everything a visitor can see; it does not log in, so it cannot page through all comments of a video. `commentCount` on the video row gives the full total.

**How many danmaku can I get?**
The public danmaku pool of a video: up to 1,000–8,000 lines depending on video length (Bilibili's own cap). For multi-part videos the danmaku of the first part are returned.

**Are commenter names exported?**
No. For privacy, comments and danmaku contain no author names, ids, avatars, IP regions or sender hashes – only text, time and engagement. Only public uploader (channel) names and ids are included.

**I see `BLOCKED` error rows.**
Bilibili sometimes applies risk control (HTTP 412 / code -352) to datacenter IPs. The Actor already rotates visitor cookies and retries; if it persists, enable **Proxy configuration → Apify Proxy → RESIDENTIAL**.

**Can it download videos?**
No. It extracts metadata, comments and danmaku only.

**Does it support b23.tv short links?**
Not directly – open the short link once and paste the full `bilibili.com/video/BV…` link.

### Is it legal to scrape Bilibili?

This Actor extracts only publicly available data that Bilibili shows to any logged-out visitor. It does not log in, bypass paywalls or collect personal data of commenters. Scraped content can still be copyrighted, so make sure your use complies with applicable laws (e.g. GDPR, PIPL) and Bilibili's terms of service. Do not use the data for spam or harassment. If unsure, consult a lawyer.

### Related actors

Related actors by the same developer:

- Douban Scraper – Movies, Books, Ratings, Comments & Reviews
- Telegram Channel Scraper – Posts, Messages & Views, No Login
- Bluesky Scraper – Posts, Search, Profiles & Followers
- Steam Reviews & Games Scraper – Prices, Players & Top Sellers
- Google Trends Scraper – Interest Over Time & Related Queries
- Keyword Suggestions – Google, YouTube, Amazon & Bing Autocomplete

### Support & feedback

Missing a field or mode? Open an issue in the **Issues** tab – feature requests are welcome.

# Actor input Schema

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

<b>popular</b> = Bilibili's current popular (热门) list. <b>ranking</b> = top-100 ranking (排行榜) of a category. <b>search</b> = videos matching your keywords. <b>videos</b> = specific videos from links / BV ids. <b>searchUploaders</b> = uploader (UP主) channels matching your keywords.

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

Used by <b>search</b> and <b>searchUploaders</b>. Chinese or English keywords, one per line, e.g. <code>原神</code>, <code>minecraft</code>, <code>影视飓风</code>.

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

Used by <b>videos</b>. Accepts <code>https://www.bilibili.com/video/BV1xx411c7mD</code>, <code>BV1xx411c7mD</code> or <code>av170001</code>.

## `rankingCategory` (type: `string`):

Used by <b>ranking</b>. The Bilibili zone whose top-100 list you want.

## `rankingType` (type: `string`):

Used by <b>ranking</b>. <b>all</b> = overall, <b>origin</b> = original content only, <b>rookie</b> = new uploaders.

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

Used by <b>search</b>.

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

Maximum videos per run (per keyword in search modes). Popular list has up to ~500 videos, rankings 100, search up to 1,000 per keyword. You pay per video, so this also caps your cost.

## `includeTags` (type: `boolean`):

Load the tag list of every video (one extra request per video, no extra charge). Search results already include tags.

## `includeComments` (type: `boolean`):

Also scrape comments of each video (pinned + hot comments and their replies). Commenter names and ids are NOT exported. Charged per comment.

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

Upper limit of comments per video. Note: Bilibili shows visitors (no login) only the top hot comments and the first page of replies under each, typically 20-70 comments per video.

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

Also scrape the danmaku (弹幕) of each video with their video timestamp, text, display mode and color. Sender ids are NOT exported. Charged per danmaku line.

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

Upper limit of danmaku lines per video (sorted by video time). Bilibili's public danmaku pool holds up to 1,000-8,000 lines per video depending on its length. 0 = all available.

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

Optional. Bilibili sometimes answers datacenter IPs with risk-control blocks (HTTP 412 / code -352). If you see 'BLOCKED' error rows, enable Apify Proxy with the RESIDENTIAL group.

## Actor input object example

```json
{
  "mode": "search",
  "searchQueries": [
    "原神",
    "minecraft"
  ],
  "videoUrls": [
    "https://www.bilibili.com/video/BV1xx411c7mD",
    "BV17x411w7KC"
  ],
  "rankingCategory": "4",
  "rankingType": "all",
  "searchOrder": "click",
  "maxItems": 50,
  "includeTags": false,
  "includeComments": true,
  "maxCommentsPerVideo": 50,
  "includeDanmaku": true,
  "maxDanmakuPerVideo": 500,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

All scraped items in the default dataset (JSON, CSV, Excel and more via the dataset export).

## `files` (type: `string`):

Records saved in the default key-value store, e.g. the run summary.

# 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": "popular",
    "maxItems": 20,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("openharvest/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": "popular",
    "maxItems": 20,
    "proxyConfiguration": { "useApifyProxy": False },
}

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

```

## MCP server setup

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