# Bilibili Scraper: Videos, Comments, Search & Popular (`apisamurai/bilibili-scraper`) Actor

Bilibili Scraper for videos by keyword, the videos of any user, single videos by link, comments and the popular list. Views, likes, coins, favorites, danmaku and dates. No login, date and views filters, pay only for real rows.

- **URL**: https://apify.com/apisamurai/bilibili-scraper.md
- **Developed by:** [API Samurai](https://apify.com/apisamurai) (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

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/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, Comments, Search & Popular

This Bilibili Scraper gets Bilibili videos by keyword, the latest videos of any user, single videos by link, the comments under a video, and the live popular list. Every row comes with a clean title (no HTML), author, date, duration, cover and link, plus views, likes, coins, favorites, shares, comments and danmaku where Bilibili shows them. You pay only for real, unique rows, and IDs are always text.

### What you can use it for

- **Track a game, brand or topic on Bilibili** with keyword search, sorted by relevance, newest, views, favorites or danmaku.
- **Follow creators** and archive their videos with dates and view counts.
- **Check single videos** by link for full counts: views, likes, coins, favorites, shares, comments and danmaku.
- **Read the comments** under videos for sentiment analysis, fan feedback or research.
- **Watch what is popular** right now with the popular list.
- **Build Chinese-language datasets** of video titles, descriptions and comments for AI and NLP work.
- **Monitor on a schedule** with a date filter, and send new rows to Sheets, Slack or a database.

### Fair billing

- Only real rows are charged: videos and comments. No demo, mock or placeholder rows, ever. If the data source sends one, it is dropped and counted in the run summary.
- Same price on every Apify plan, free plan included.
- Free Apify plan: 3 live runs a day, each with one data request, so you can try it. Paid plans have no limit.
- Limits, dates and views filters are enforced by the Actor itself. Videos outside your dates or filters are skipped and not charged.
- Duplicates are never charged. A video found by two keywords, or by a keyword and a link, is saved once.
- Empty results, missing users or videos, videos with no comments and failed requests cost nothing.
- When you hit your spending limit, the run stops cleanly.

### How to use

1. Open the [Bilibili Scraper](https://apify.com/apisamurai/bilibili-scraper) page and click **Try for free** (you sign in to your Apify account).
2. Add **Search keywords**, **Users** (numeric IDs or profile links), **Video links**, or turn on **Add the popular videos list**.
3. Set **Max videos per keyword or user**, and optionally dates and min views. Turn on **Also get comments of the videos found** to add comments.
4. Click **Start**. Rows appear in the **Output** tab while the run works.
5. Export the dataset as JSON, CSV or Excel, or check the `SUMMARY` record in the key-value store.

### Input

| Field | What it does |
|---|---|
| Search keywords | Videos matching each keyword, one per line. Chinese keywords work best. |
| Sort search by | Relevance (default), newest, most views, most favorites or most danmaku. |
| Users | Numeric user IDs or profile links: `546195`, `https://space.bilibili.com/546195`. Latest videos first. |
| Video links | `https://www.bilibili.com/video/BV1HvkqzAEav` or the bare `BV...` ID. Short `b23.tv` links are rejected with a log line and no charge. |
| Also get comments of the videos found | Off by default. Adds the comments of videos from keywords, users and video links. |
| Add the popular videos list | Off by default. Adds the current popular list. |
| Max videos per keyword or user | Default 20, exact. |
| Max comments per video | Default 20, exact. |
| Max rows for the whole run | Optional hard cap on all rows. Videos are saved before comments. |
| Posted on or after / on or before | Inclusive, UTC. Relative dates like `7 days` work. Videos only. |
| Min views | Skip videos below this number. Videos only. |

```json
{
  "searchKeywords": ["原神"],
  "searchSort": "newest",
  "users": ["546195"],
  "includeComments": true,
  "maxVideosPerSource": 20,
  "maxCommentsPerVideo": 20,
  "postedAfter": "7 days"
}
```

### Output

One row per video or comment; `type` tells them apart. Field names never change between runs. Real output (2 December 2026, shortened):

```json
{
  "type": "video",
  "id": "BV1HvkqzAEav",
  "aid": "117717554240943",
  "url": "https://www.bilibili.com/video/BV1HvkqzAEav",
  "title": "【原神萌新开荒49】须弥主线第四幕|听我号令，随时准备向教令院开炮！！",
  "description": "直播回放|20年游戏女玩家原神开荒DAY49（2026.12.02）...",
  "createdAt": "2026-12-02T16:38:11.000Z",
  "durationSeconds": 15946,
  "category": "手机游戏",
  "tags": ["电子榨菜", "原神UP主激励计划", "直播回放", "..."],
  "cover": "https://i2.hdslb.com/bfs/archive/873a5416277f9d5c9148967c53f2ec81511fb094.jpg",
  "author": { "id": "202798450", "name": "花花梨i" },
  "views": 149,
  "likes": 22,
  "coins": null,
  "favorites": 4,
  "shares": null,
  "comments": 4,
  "danmaku": 2,
  "sourceType": "search",
  "sourceInput": "原神",
  "scrapedAt": "2026-12-02T17:00:00.000Z"
}
```

A comment row: `{ "type": "comment", "id": "325766602816", "videoId": "BV1HvkqzAEav", "url": "https://www.bilibili.com/video/BV1HvkqzAEav", "text": "请选择正确的干员代号: ...", "createdAt": "2026-12-02T03:00:41.000Z", "likes": 4951, "replyCount": 370, "author": { "id": "177117312", "name": "ChrT-NULL-", "level": 6 }, "sourceInput": "BV1HvkqzAEav", "scrapedAt": "..." }`.

Times are ISO 8601 UTC. `sourceType` is `search`, `user`, `popular` or `link`. Missing values are `null`, never a fake 0. Where each route has data:

- **Video links and the popular list** return every count (views, likes, coins, favorites, shares, comments, danmaku). A video by link also has the full description.
- **Keyword search** has views, likes, favorites, comments and danmaku, and a category and tags, but no coins or shares (`null`).
- **A user's videos** have author ID and name, title, link, cover, date, duration, category, views and danmaku. Likes, coins, favorites, shares and comments are `null`, and so are the description and tags. Use a video link for full counts.

Each run also writes a `SUMMARY` record to the key-value store. For every input it lists rows delivered, rows skipped by dates or filters, duplicates, and why it stopped (`limit reached`, `no more results`, `not found or deleted`, `temporary error`, `spending limit`, `free plan limit` or `data source unavailable`).

### Pricing

$2 per 1,000 videos; $5 per 1,000 videos by link; $2 per 1,000 comments; $0.005 per run start

A video fetched by its link costs more because each link needs a data request of its own.

### Integrations

- **Apify API:** start a run and get the rows in one call with `POST https://api.apify.com/v2/acts/apisamurai~bilibili-scraper/run-sync-get-dataset-items?token=<YOUR_APIFY_TOKEN>` and the input as JSON in the body.
- **Python and JavaScript clients** (`apify-client`): `client.actor("apisamurai/bilibili-scraper").call(run_input={...})`.
- **Zapier, Make and n8n** to send new rows to Google Sheets, Slack, a CRM or a database.
- **MCP for AI agents:** connect the Apify MCP server to Claude, ChatGPT or another MCP client and the agent can run this Actor as a tool.
- **Schedules and webhooks** in Apify Console for daily or hourly runs.

### More China platform scrapers

- [Douyin Scraper](https://apify.com/apisamurai/douyin-scraper): Douyin videos by keyword (up to 1,000 per search), user videos, comments and the hot list.
- [Weibo Scraper](https://apify.com/apisamurai/weibo-scraper): Weibo posts by keyword or user, comments and the live hot search list.
- [Zhihu Scraper](https://apify.com/apisamurai/zhihu-scraper): Zhihu answers and articles by keyword, question or user, comments and the hot list.

### FAQ

**Do I need a Bilibili account?**
No. You only need an Apify account. You never enter credentials, cookies or a session.

**Which keywords work best?**
Chinese keywords. English words work but find fewer videos. Pick the sort order that fits: relevance, newest, most views, most favorites or most danmaku.

**Which videos and users work?**
Public videos and users. Use `bilibili.com/video/<BV id>` or the bare BV ID, and the numeric user ID from `space.bilibili.com/<number>`. Old `av` links and short `b23.tv` links cannot be read: open them in a browser and copy the full `BV` address.

**What time zone are dates in?**
`createdAt` is UTC. "Posted on or after / before" count whole days in UTC. With dates set, keyword search asks Bilibili for exactly that window.

**How far back can I go?**
A user's videos are read newest first, 20 a page, and stop once they are older than your start date. Keyword search can go back as far as Bilibili returns results, which is limited to about 50 pages of 20.

**Do filters work on comments?**
No. Dates and min views apply to videos. Comments are limited by **Max comments per video** and **Max rows for the whole run**.

**Why did I get fewer results than I asked for?**
Open the `SUMMARY` record. It says for each input why it stopped: no more results, rows skipped by dates or filters, duplicates, the spending limit or the free plan limit.

**What is not charged?**
Duplicates, rows outside your dates or filters, placeholder rows, empty results, missing users or videos, videos with no comments, rejected links and failed requests.

**Is it legal to scrape Bilibili?**
The Actor collects only public data. You are responsible for how you use it: follow the Bilibili terms and the laws where you live, and take care with personal data (for example under GDPR or China's PIPL). This is not legal advice.

# Actor input Schema

## `searchKeywords` (type: `array`):

Find videos that match these keywords. One per line. Chinese keywords work best, for example 原神. Results come in Bilibili's relevance order unless you pick another sort below.

## `searchSort` (type: `string`):

How keyword search results are ordered.

## `users` (type: `array`):

Get the latest videos of these accounts. Numeric user IDs or profile links: 546195 or https://space.bilibili.com/546195. One per line.

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

Get these videos with full counts, e.g. https://www.bilibili.com/video/BV1HvkqzAEav or just BV1HvkqzAEav. Short b23.tv links cannot be read: open them and copy the full address. One per line.

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

On: for the videos saved from keyword search, users and video links, also save their comments (up to Max comments per video). A video with no comments costs nothing.

## `includePopular` (type: `boolean`):

On: also save the current Bilibili popular videos list, with full counts.

## `maxVideosPerSource` (type: `integer`):

Maximum videos saved for each keyword, each user and the popular list. Enforced exactly.

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

Maximum comments saved for each video. Enforced exactly.

## `maxTotalItems` (type: `integer`):

Optional hard cap on all rows (videos and comments) across the run. Videos are saved before comments. Leave empty for no total cap.

## `postedAfter` (type: `string`):

Only videos published on or after this day (UTC). Also accepts relative dates such as 7 days. Applies to videos, not comments. Videos outside the range are skipped and not charged. A user's list stops once its videos are older than this day.

## `postedBefore` (type: `string`):

Only videos published on or before this day (UTC, the whole day is included). Videos outside the range are skipped and not charged.

## `minViews` (type: `integer`):

Skip videos with fewer views. Skipped videos are not charged.

## Actor input object example

```json
{
  "searchKeywords": [
    "原神"
  ],
  "searchSort": "relevance",
  "includeComments": false,
  "includePopular": false,
  "maxVideosPerSource": 20,
  "maxCommentsPerVideo": 20
}
```

# Actor output Schema

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

Video rows from keyword search have views, likes, favorites, comments, danmaku, category and tags (no coins or shares). Rows from a user have author name, views, danmaku, category and duration only (likes, coins, favorites, shares, comments, description and tags are null). Rows from a video link or the popular list have all counts. Comment rows have text, likes, reply count and author.

## `summary` (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 = {
    "searchKeywords": [
        "原神"
    ],
    "maxVideosPerSource": 20,
    "maxCommentsPerVideo": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("apisamurai/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 = {
    "searchKeywords": ["原神"],
    "maxVideosPerSource": 20,
    "maxCommentsPerVideo": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("apisamurai/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 '{
  "searchKeywords": [
    "原神"
  ],
  "maxVideosPerSource": 20,
  "maxCommentsPerVideo": 20
}' |
apify call apisamurai/bilibili-scraper --silent --output-dataset

```

## MCP server setup

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