# Bilibili Video Scraper – Search, Video Stats & Comments (哔哩哔哩) (`romantic_boysenberry/bilibili-video-scraper`) Actor

Scrape Bilibili (哔哩哔哩, B站) videos by keyword, video stats (views, likes, coins, favorites, shares, danmaku) by BV/av id or URL, and top comments. Public web API with WBI signing, no login, no API key, no browser. $1 per 1,000 items.

- **URL**: https://apify.com/romantic_boysenberry/bilibili-video-scraper.md
- **Developed by:** [정무 최](https://apify.com/romantic_boysenberry) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 results

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 Video Scraper – Search, Video Stats & Comments (哔哩哔哩)

**Bilibili Video Scraper** extracts public data from **Bilibili (哔哩哔哩, B站)**, China's largest video community with more than 300 million monthly users. Search any keyword and get a list of videos with play counts, likes and tags; paste BV or av ids and get full statistics (views, likes, coins, favorites, shares, danmaku, replies); or pull the top comments under any video. Results land in your dataset as clean JSON, CSV or Excel.

No Bilibili account. No API key. No headless browser. Pay only for the items you receive.

### What does Bilibili Video Scraper do?

Bilibili has no official data API for third parties. This Bilibili scraper calls the same public JSON endpoints that the bilibili.com website itself uses, including the WBI request signature that Bilibili added in 2023 and that breaks most older Bilibili scrapers. Three modes cover the three things people actually need from Bilibili:

| Mode | Input | One dataset item is |
|---|---|---|
| `search` | keywords (关键词) | one video from the search results, with play, danmaku, like, favorites, duration, tags, author |
| `video` | video URLs, BV ids or av ids | one video with full stats: view, like, coin, favorite, share, reply, danmaku, owner, description, publish date |
| `comments` | video URLs, BV ids or av ids | one top-level comment: text, likes, reply count, time, public username |

That covers Bilibili keyword research, UP主 (creator) monitoring, trend tracking, competitor analysis and Chinese-language sentiment datasets with a single Actor.

### Why use this Bilibili scraper?

- **WBI signing built in.** Bilibili's `w_rid` / `wts` signature is implemented from the public mixin table and refreshed automatically when keys rotate, so `video` and `search` requests do not fail with `-403` or HTTP 412 the way unsigned scrapers do.
- **Correct pagination.** Search pages use a fixed page size and are deduplicated by `bvid`, so `maxItems: 100` returns 100 distinct videos, not 60 with repeats.
- **Pure HTTP, no browser.** A run finishes in seconds and uses 512 MB of memory, so platform cost is minimal.
- **Loud failures.** If Bilibili changes its response shape, Bilibili Video Scraper fails with an explicit error instead of returning an empty, billed-looking success.
- **Pay per item.** $1.00 per 1,000 videos or comments, billed only for results that reach your dataset.
- **Ready for AI agents.** Every Apify Actor is also an API endpoint and an MCP server, so Claude, ChatGPT, LangChain, n8n or Make can call Bilibili Video Scraper directly.

### Output: what data can you extract from Bilibili?

#### `search` mode: one item per video

| Field | Example | Description |
|---|---|---|
| `keyword` | `python` | The keyword that produced this result |
| `bvid` | `BV1rpWjevEip` | Bilibili video id (BV format) |
| `aid` | `113006243481679` | Numeric video id (av number) |
| `title` | `【全748集】目前B站最全最细的Python零基础全套教程` | Title with search highlighting removed |
| `description` | `本套教程从零开始讲解...` | Short description |
| `author` | `Python官方课程` | Uploader (UP主) display name |
| `mid` | `3546597933714079` | Uploader's public user id |
| `play` | `20592822` | Play count |
| `danmaku` | `132365` | Bullet comment (弹幕) count |
| `like` | `565892` | Likes |
| `favorites` | `870433` | Favorites (收藏) |
| `reply` | `357983` | Comment count |
| `duration` | `2398:14` | Duration as shown by Bilibili (`mm:ss`) |
| `pubdate` / `pubdateIso` | `1724338758` / `2024-08-22T14:59:18.000Z` | Publish time as Unix seconds and ISO 8601 |
| `typename` | `计算机技术` | Bilibili category |
| `tags` | `["程序员","Python教程"]` | Tags as an array |
| `pic` | `https://i2.hdslb.com/bfs/archive/....jpg` | Cover image |
| `url` | `https://www.bilibili.com/video/BV1rpWjevEip` | Video page |

#### `video` mode: one item per video

| Field | Example | Description |
|---|---|---|
| `bvid`, `aid`, `title`, `description` | | As above, with the full description |
| `ownerName` / `ownerMid` | `Python官方课程` / `3546597933714079` | Uploader name and public id |
| `view` | `20592871` | Views |
| `like` | `565906` | Likes |
| `coin` | `404366` | Coins (投币) |
| `favorite` | `870441` | Favorites (收藏) |
| `share` | `102302` | Shares |
| `reply` | `357983` | Comments |
| `danmaku` | `132365` | Bullet comments |
| `duration` | `143894` | Total duration in seconds |
| `partCount` | `100` | Number of parts (分P) |
| `copyright` | `original` | `original` (自制) or `repost` (转载) |
| `pubdate` / `pubdateIso`, `typename`, `pic`, `url` | | As above |

#### `comments` mode: one item per comment

| Field | Example | Description |
|---|---|---|
| `bvid` / `aid` / `videoTitle` | | The video the comment belongs to |
| `rpid` | `247714016448` | Comment id (use to deduplicate between runs) |
| `content` | `孩子们课代表来了...` | Comment text |
| `like` | `7473` | Likes on the comment |
| `replyCount` | `1146` | Number of replies under this comment |
| `ctime` / `ctimeIso` | `1732197161` / `2024-11-21T13:52:41.000Z` | Posted time |
| `uname` | `爱劳动的noise` | Public username |
| `mid` | `1242205079` | Commenter's public user id |
| `userLevel` | `4` | Bilibili account level 0 to 6 |
| `url` | `https://www.bilibili.com/video/BV1rpWjevEip#reply247714016448` | Deep link to the comment |

Example output (`video` mode, JSON):

```json
{
  "bvid": "BV1rpWjevEip",
  "aid": 113006243481679,
  "title": "【全748集】目前B站最全最细的Python零基础全套教程，2026最新版",
  "description": "本套教程从零开始讲解，手把手教学，包含基础语法、进阶语法、爬虫、自动化办公、数据分析",
  "ownerName": "Python官方课程",
  "ownerMid": 3546597933714079,
  "view": 20592871,
  "danmaku": 132365,
  "reply": 357983,
  "favorite": 870441,
  "coin": 404366,
  "share": 102302,
  "like": 565906,
  "duration": 143894,
  "pubdate": 1724338758,
  "pubdateIso": "2024-08-22T14:59:18.000Z",
  "typename": null,
  "partCount": 100,
  "copyright": "original",
  "pic": "https://i2.hdslb.com/bfs/archive/a979056b1a32012cdd00d48fbc3732d253e30620.jpg",
  "url": "https://www.bilibili.com/video/BV1rpWjevEip"
}
```

Download the dataset as JSON, CSV, Excel, XML or RSS from the Apify Console, or fetch it through the API.

### How to scrape Bilibili videos and comments

1. Open **Bilibili Video Scraper** in Apify Store and click **Try for free**.
2. Pick a **mode**: `search`, `video` or `comments`.
3. For `search`, enter **keywords** such as `python`, `原神` or `鬼畜`. For `video` or `comments`, paste **video URLs or ids** such as `https://www.bilibili.com/video/BV1rpWjevEip` or `av170001`.
4. Set **Max items** (default 50). In `search` it is videos per keyword, in `comments` it is comments per video.
5. Click **Start**. Results appear in the **Output** tab within seconds.
6. Export, or schedule the run to repeat daily for monitoring.

#### Where do I find a Bilibili video id?

Every Bilibili video URL contains a BV id. Older links and the mobile app also show an av number. Both work:

```
https://www.bilibili.com/video/BV1rpWjevEip/   →  BV1rpWjevEip
https://www.bilibili.com/video/av170001          →  av170001  (or just 170001)
https://b23.tv/BV1rpWjevEip                      →  BV1rpWjevEip
```

### Input parameters

| Parameter | Type | Default | Description |
|---|---|---|---|
| `mode` | string | `search` | `search`, `video` or `comments`. |
| `keywords` | array | `["python"]` | Bilibili search queries, used in `search` mode. Chinese or English, one video list per keyword. |
| `videoUrlsOrIds` | array | `["BV1rpWjevEip"]` | Video URLs, BV ids or av ids, used in `video` and `comments` mode. |
| `maxItems` | integer | `50` | `search`: videos per keyword (1 to 5000). `comments`: comments per video. `video`: total videos. |
| `proxyConfiguration` | object | no proxy | Bilibili's public API answers Apify's datacenter IPs directly. Add a proxy only if the log shows HTTP 412. |

Example input:

```json
{
  "mode": "search",
  "keywords": ["python 教程", "机器学习"],
  "maxItems": 100,
  "proxyConfiguration": { "useApifyProxy": false }
}
```

```json
{
  "mode": "comments",
  "videoUrlsOrIds": ["https://www.bilibili.com/video/BV1rpWjevEip", "av170001"],
  "maxItems": 200
}
```

### How much does it cost to scrape Bilibili?

Bilibili Video Scraper uses Apify's **pay-per-event** pricing: **$0.001 per item** ($1.00 per 1,000 videos or comments). You are charged only for items that land in your dataset. A run that returns nothing costs nothing beyond Apify platform usage.

| Items | Price |
|---|---|
| 1,000 | $1.00 |
| 10,000 | $10.00 |
| 100,000 | $100.00 |

Apify's free plan includes $5 of monthly usage, enough for several thousand items to evaluate the Actor. Because the Actor downloads only small JSON payloads and needs no proxy by default, platform compute per item is negligible.

### Use cases for Bilibili data

- **Keyword and trend research:** Which videos rank for `AI 绘画` or `露营` this week, and how many plays do they have? Schedule a daily `search` run and chart the movement.
- **UP主 and competitor monitoring:** Pass your own and competitor video ids in `video` mode to track views, likes, coins and favorites over time.
- **Sponsorship and influencer vetting:** Compare like-to-view and coin-to-view ratios across a creator's catalog before signing a 商单.
- **Chinese NLP and LLM datasets:** Thousands of authentic, informal Chinese comments with like counts for sentiment analysis, slang research or fine-tuning.
- **Market research for China:** See how Chinese consumers talk about a product, game or anime in Bilibili comments.
- **AI agents:** Let an agent answer "what are the most-played Bilibili videos about X?" by calling the Actor through MCP.

### Use Bilibili Video Scraper from code

**Python**

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_API_TOKEN>")
run = client.actor("romantic_boysenberry/bilibili-video-scraper").call(run_input={
    "mode": "search",
    "keywords": ["python"],
    "maxItems": 100,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["bvid"], item["play"], item["title"][:50])
```

**JavaScript**

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: '<YOUR_API_TOKEN>' });
const run = await client.actor('romantic_boysenberry/bilibili-video-scraper').call({
  mode: 'comments',
  videoUrlsOrIds: ['BV1rpWjevEip'],
  maxItems: 200,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.length, 'comments');
```

**cURL**

```bash
curl -X POST "https://api.apify.com/v2/acts/romantic_boysenberry~bilibili-video-scraper/run-sync-get-dataset-items?token=<YOUR_API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"mode":"video","videoUrlsOrIds":["BV1rpWjevEip","av170001"]}'
```

The Actor also works as an **MCP server** for Claude Desktop, Cursor and other agents, and plugs into **n8n**, **Make**, **Zapier** and **LangChain** through the standard Apify integrations.

### Tips for best results

- Chinese keywords match Bilibili's audience better than English ones, but both work. `python 教程` returns more tutorial videos than `python tutorial`.
- Search returns at most 1,000 results per keyword (Bilibili's own cap, 20 pages of 50). Use several narrower keywords to go deeper.
- `search` mode already includes play, like, favorites and danmaku counts. Use `video` mode only when you need coins, shares, the full description or part count.
- Comments are returned in Bilibili's "hot" order, which is what visitors see first. Deduplicate on `rpid` when you run on a schedule.
- Keep `maxItems` small for daily deltas; it is the only thing that drives cost.

### Limitations

- Only data visible to logged-out visitors is collected. Videos restricted to members, age-gated content and comments hidden by the uploader are not available.
- `comments` mode returns top-level comments. Replies under a comment are counted in `replyCount` but not expanded.
- Some videos only expose "selected comments" (精选评论) to visitors; for those the Actor returns the handful Bilibili shows, not the full count.
- Bilibili applies risk control (HTTP 412) to IP ranges it dislikes. The Actor fetches a device cookie and signs every request, which is enough for Apify's IPs today; if you see 412 in the log, enable a residential proxy.
- Bilibili changes its web API occasionally. If a run suddenly returns zero items, the Actor fails loudly instead of silently succeeding; check the run log and open an issue.

### Legal and ethical use

Bilibili Video Scraper collects only publicly visible video metadata, statistics and comment text with the public username shown on the comment. It does not log in, does not bypass access controls, does not download video files and does not collect private contact details. Video titles, descriptions and comments may be protected by copyright and personal data rules in your jurisdiction; use the data for analysis, research and monitoring in line with [Bilibili's terms](https://www.bilibili.com/blackboard/activity-fcGzGRu6zY.html) and applicable law, including China's Personal Information Protection Law. You are responsible for how you use the output.

### FAQ

**Does Bilibili have an official API?**
Not for third parties. The endpoints used here are the public web endpoints that bilibili.com itself calls, signed with the public WBI scheme. This Actor does not use any private or leaked key.

**Why do other Bilibili scrapers return empty results or errors?**
Since 2023 most Bilibili endpoints require a `buvid3` device cookie and a `w_rid` WBI signature. Scrapers written before that get HTTP 412 or code `-403`. Bilibili Video Scraper implements both.

**Can I scrape a whole UP主 channel?**
Not yet. Search for the creator's name in `search` mode, or pass their video ids to `video` mode. A creator-videos mode is planned.

**Can it download the video or subtitles?**
No. This Actor returns metadata, statistics and comments only.

**How fresh is the data?**
Every run fetches live from Bilibili. Nothing is cached.

**Can I run it on a schedule?**
Yes. Use Apify Schedules to run hourly, daily or weekly, and connect a webhook or integration to receive new items automatically.

**Is there a free trial?**
Apify's free plan gives you $5 of usage every month, so you can test Bilibili Video Scraper without a credit card.

### Related Actors

- [Bilibili Scraper](https://apify.com/scraper-mind/bilibili-scraper) for a browser-based alternative
- [Bilibili Video Downloader](https://apify.com/easyapi/bilibili-video-downloader) if you need the media file itself
- [Douyin Scraper](https://apify.com/clockworks/douyin-scraper) for Chinese short video data
- [Naver Place Reviews Scraper](https://apify.com/romantic_boysenberry/naver-place-reviews-scraper) from this developer, for Korean local reviews

***

### 哔哩哔哩视频采集器 / Bilibili 비디오 수집기 (한국어 안내)

**Bilibili Video Scraper**는 중국 최대 동영상 커뮤니티 \*\*빌리빌리(哔哩哔哩, B站)\*\*의 공개 데이터를 키워드 검색, 영상 ID, 댓글 세 가지 모드로 수집해 JSON, CSV, Excel로 내려받는 Apify 액터입니다.

- 로그인, API 키, 브라우저 설치 모두 불필요. 빌리빌리 웹사이트가 쓰는 공개 JSON API를 WBI 서명과 함께 호출
- 1건당 $0.001 (1,000건에 $1), 받은 만큼만 과금
- `search`: 키워드 → 영상 목록(재생수, 좋아요, 즐겨찾기, 탄막, 태그, 업로더) / `video`: BV·av ID → 조회수, 좋아요, 코인, 즐겨찾기, 공유, 댓글수, 설명 / `comments`: 영상 ID → 인기 댓글(본문, 좋아요, 답글 수, 작성 시각, 공개 닉네임)
- 활용: 중국 시장 트렌드 조사, UP주(크리에이터)·경쟁사 모니터링, 인플루언서 검증, 중국어 감성 분석 데이터셋
- 공개된 정보와 공개 닉네임만 수집하며 개인정보는 수집하지 않습니다. 수집 데이터는 관련 법령과 빌리빌리 약관을 지켜 사용하세요

사용법: 액터 페이지에서 **Try for free** → 모드 선택 → 키워드(예: `python`) 또는 영상 URL 입력 → **Start** → Output 탭에서 다운로드. 예약 실행(Schedules)으로 매일 자동 수집도 가능합니다.

# Actor input Schema

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

search: keywords -> videos (one item per video). video: BV/av ids or URLs -> full stats (one item per video). comments: BV/av ids or URLs -> top comments (one item per comment).

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

Used in mode "search". Bilibili search queries, e.g. "python", "原神", "鬼畜". Each keyword yields up to maxItems videos, sorted by Bilibili relevance.

## `videoUrlsOrIds` (type: `array`):

Used in modes "video" and "comments". Accepts https://www.bilibili.com/video/BV1rpWjevEip, BV1rpWjevEip, av170001 or a bare aid.

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

search: videos per keyword. comments: comments per video. video: total videos. Billing is per item pushed.

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

Optional. Bilibili's public API answers Apify datacenter IPs without a proxy; add one only if you see HTTP 412 in the log.

## Actor input object example

```json
{
  "mode": "search",
  "keywords": [
    "python"
  ],
  "videoUrlsOrIds": [
    "BV1rpWjevEip"
  ],
  "maxItems": 50,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `items` (type: `string`):

No description

# 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",
    "keywords": [
        "python"
    ],
    "videoUrlsOrIds": [
        "BV1rpWjevEip"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("romantic_boysenberry/bilibili-video-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",
    "keywords": ["python"],
    "videoUrlsOrIds": ["BV1rpWjevEip"],
    "proxyConfiguration": { "useApifyProxy": False },
}

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

```

## MCP server setup

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