# Bilibili Scraper: Video Search, Stats, Comments & Trending (`polyglot-data/bilibili-scraper`) Actor

Search Bilibili by keyword, video URL or channel ID, or pull trending videos and comments. Video stats (views, likes, danmaku) for China video and creator research. No login.

- **URL**: https://apify.com/polyglot-data/bilibili-scraper.md
- **Developed by:** [Polyglot Data](https://apify.com/polyglot-data) (community)
- **Categories:** Social media, Videos
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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/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, Comments & Trending (China's YouTube)

![Bilibili Scraper example output](https://api.apify.com/v2/key-value-stores/5noGfeHp3GYPBOMYQ/records/bilibili-banner.png?signature=100UbCNwGeJIv84DTJuP5)

A **Bilibili scraper** for the public guest API of bilibili.com, the biggest video site in China ("China YouTube"). Five modes: **Bilibili search**, video details and stats, **Bilibili comments**, the popular (trending) list, and the latest uploads of a channel. No login, no cookies from you, no browser.

- 🔎 **Search**: keywords in Chinese or English, order by best match, plays, newest, danmaku or favorites, optional duration filter, up to 50 pages (1,000 results) per keyword.
- 🎬 **Video details**: views, likes, coins, favorites, shares, danmaku (bullet comments), comment count, tags, uploader, publish time, duration.
- 💬 **Comments**: text, likes, time, user name and level, reply count, with replies. See the guest limit below.
- 🔥 **Popular**: the current trending list with full stats.
- 📺 **Channels**: latest uploads of any uploader (`space.bilibili.com/<id>`).
- Accepts `bilibili.com/video/BV...` links, bare BV ids, and `b23.tv` short links.
- 💸 **Pay per event**: $2.00 per 1,000 videos, $0.50 per 1,000 comments. Error items are free.

### ⚠️ Honest limits (guest access)

Bilibili restricts what logged-out visitors can read. This Actor never logs in, so:

- **Comments: about 3 top-level comments per video per sort order** (hot and latest, so up to ~6), then the **first 20 replies** under each of them. Deeper pages come back empty for guests. A video yields roughly 40 to 100 comments at most, however many it has. The IP location label is not shown to guests, so `location` is usually `null`.
- **Search** never goes beyond 50 pages (1,000 results) per keyword, a Bilibili cap. Use more specific keywords or filters for deeper coverage.
- **Channels** use a public archive list that shows only the view count for each video (no likes, coins, comment count, uploader name). Run `videos` mode on the links for full stats.
- The popular list is the one Bilibili serves to guests; it changes through the day.
- Bilibili has strict risk control. The Actor is deliberately slow (1 to 2 seconds per request), and stops with a `BLOCKED` item instead of hammering the site. On Apify it uses residential proxy and switches IP automatically.
- Only public content: no members-only or paid videos, no private data.

### 📦 What data you get

**Video item** (search, videos, popular, channels):

| Field | Description |
|---|---|
| `bvid`, `aid`, `url` | Video ids and page link |
| `title`, `description`, `coverUrl`, `tags` | Title (highlight tags removed), description, cover, tags (videos mode) |
| `authorName`, `authorMid`, `authorUrl` | Uploader |
| `durationSeconds`, `publishedAt`, `category` | Length, publish time (ISO), Bilibili category |
| `views`, `danmaku`, `comments`, `likes`, `favorites` | Counters |
| `coins`, `shares` | Counters, in videos and popular modes |
| `source`, `keyword`, `scrapedAt` | search / video / popular / channel, the keyword that found it |

**Comment item** (comments mode): `rpid`, `videoBvid`, `videoUrl`, `videoTitle`, `text`, `likes`, `publishedAt`, `userName`, `userMid`, `userLevel`, `replyCount`, `isReply`, `parentRpid`, `location` (when shown).

Fields Bilibili does not show are `null`.

#### Example video item

```json
{
  "type": "video",
  "bvid": "BV1KoWBzwE7T",
  "url": "https://www.bilibili.com/video/BV1KoWBzwE7T",
  "title": "最薄的iPhone...代价呢？国行iPhone Air上手体验",
  "authorName": "影视飓风",
  "authorMid": "946974",
  "durationSeconds": 642,
  "publishedAt": "2025-10-17T01:00:00.000Z",
  "views": 6987667,
  "danmaku": 9147,
  "comments": 9173,
  "likes": 126213,
  "favorites": 20944,
  "source": "search",
  "keyword": "iphone 17"
}
```

#### Error items

One free item explains why an input gave nothing: `NO_RESULTS`, `NOT_FOUND`, `NO_COMMENTS`, `INVALID_INPUT`, `NO_KEYWORDS`, `NO_URLS`, `UNAVAILABLE`, and `BLOCKED` (risk control kept answering even after switching IPs; run again later).

### 🚀 How to use

1. Pick a **Mode**.
2. `search`: add **Keywords**. `videos`, `comments`: add video **links**. `channels`: add space links or user ids. `popular`: nothing to add.
3. Set **Max items**. It is split evenly between inputs; an input with fewer results hands its share to the next ones.
4. Click **Start**. Download JSON, CSV, Excel or HTML, or use the API.

```json
{ "mode": "comments", "urls": ["https://www.bilibili.com/video/BV1WvykzsEmt", "https://b23.tv/AbCdEf"], "maxItems": 80, "includeReplies": true }
```

### 🎯 Use cases

Trend and creator research on Chinese video, tracking views and danmaku of a topic, competitor and influencer monitoring, comment sentiment samples, content discovery for translators and clippers.

### 💰 Pricing

Pay per event: **$0.002 per video** and **$0.0005 per comment** saved, plus a tiny start fee. Error items and duplicates are never charged. 100 videos cost about $0.20. Set a maximum cost per run to cap spending.

### 🔒 Privacy and legal

Reads only public guest endpoints: no login, no paid or members content. Comments contain public user names; use them in line with applicable data-protection laws and Bilibili's terms. You are responsible for your use of the data.

### More actors by Polyglot Data

- [Douyin Scraper](https://apify.com/polyglot-data/douyin-scraper): China's short video app.
- [1688.com Product Scraper](https://apify.com/polyglot-data/china-1688-scraper): China wholesale prices and suppliers.

# Actor input Schema

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

What to scrape. search uses Keywords; videos, comments and channels use URLs; popular needs no input.

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

One search per line, Chinese or English.

## `urls` (type: `array`):

Video links (bilibili.com/video/BV...), BV ids, b23.tv short links. For channels mode: space.bilibili.com/<id> links or numeric user ids.

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

Stop after saving this many items (videos or comments) in total. Split evenly between keywords / videos / channels; an input with fewer results hands its unused share to the next ones.

## `maxPagesPerInput` (type: `integer`):

Safety cap on result pages read per keyword / channel (20 results per search page, 30 per channel page; the popular list counts pages of 20). Bilibili search never shows more than 50 pages.

## `order` (type: `string`):

Search mode only.

## `duration` (type: `string`):

Search mode only.

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

One extra request per video to read its tags.

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

Guests see only 3 top-level comments per video; with this on, the first 20 replies under each of them are added.

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

By default the Actor uses Apify residential proxy and switches IP every 25 requests and whenever Bilibili shows its risk-control check.

## Actor input object example

```json
{
  "mode": "search",
  "keywords": [
    "iphone 17"
  ],
  "maxItems": 100,
  "maxPagesPerInput": 5,
  "order": "totalrank",
  "duration": "0",
  "includeTags": true,
  "includeReplies": true,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# 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 = {
    "keywords": [
        "iphone 17"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("polyglot-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 = {
    "keywords": ["iphone 17"],
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("polyglot-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 '{
  "keywords": [
    "iphone 17"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call polyglot-data/bilibili-scraper --silent --output-dataset

```

## MCP server setup

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