# Bilibili Video Scraper (`leorochasantos/bilibili-videos`) Actor

A scraper for public Bilibili videos: keyword search results and single videos, with title, watch URL, uploader, publish time, duration, views, likes, favorites and tags. No login, no personal data, no media download.

- **URL**: https://apify.com/leorochasantos/bilibili-videos.md
- **Developed by:** [Leonardo Santos](https://apify.com/leorochasantos) (community)
- **Categories:** Social media, Videos, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 bilibili video rows

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

Scrape public Bilibili videos: run keyword searches on Bilibili's public video
search, or resolve specific videos by URL / BV id / av id. Every row is flat,
typed and null-safe for SEO research, content monitoring, spreadsheets and
pipelines.

### Why this actor?

- Two buyer-shaped modes: `search` (keyword search results) and `detail`
  (resolve exact videos).
- One flat row per video: title, watch URL, BV id, uploader, publish time,
  duration, views, danmaku, likes, favorites, replies, tags and cover URL.
- Hard local bounds on keywords and rows keep delivery and spend predictable.
- Empty keywords, malformed or non-Bilibili inputs, videos that no longer
  exist and risk-control-blocked fetches are free error rows.
- Public JSON surface only: no login, no personal data, no media download.

### Input

```json
{"mode":"search","keywords":["python"],"maxItemsPerKeyword":20}
```

For detail mode, set `mode` to `detail` and provide `videoUrls`.

| Input | Meaning |
|---|---|
| `mode` | `search` (keyword search) or `detail` (resolve exact videos). |
| `keywords` | `search` mode: keywords, e.g. `python`, `机器学习`, `音乐`. Up to 10 per run. |
| `videoUrls` | `detail` mode: watch URLs (`https://www.bilibili.com/video/BV…`), BV ids or av ids, deduplicated and capped at 50. |
| `maxItemsPerKeyword` | Hard local cap of rows per keyword (1–50; a search page answers with 20). |
| `proxyConfiguration` | Proxy for the public Bilibili API surface; datacenter is the default. |

### Output

```json
{"mode":"search","input":"python","source_type":"search","source":"python","bvid":"BV1rpWjevEip","aid":113006243481679,"url":"https://www.bilibili.com/video/BV1rpWjevEip","title":"【全748集】目前B站最全最细的Python零基础全套教程，2026最新版，包含所有干货！七天就能从小白到大神！少走99%的弯路！存下吧！很难找全的！","description":"【视频配套籽料、开发环境搭建安装包教程、电子书+问题解答请看 ”置顶平论” 自取哦】…","author":"Python官方课程","author_mid":3546597933714079,"published_at":"2024-08-22T14:59:18.000Z","duration_secs":143894,"duration_text":"2398:14","view_count":20015980,"danmaku_count":130047,"like_count":545223,"favorite_count":840434,"reply_count":349693,"tags":["程序员","Python教程","Python入门零基础"],"cover_url":"https://i2.hdslb.com/bfs/archive/a979056b1a32012cdd00d48fbc3732d253e30620.jpg","error":null,"scraped_at":"2026-09-19T10:00:00.000Z"}
```

| Field | Meaning |
|---|---|
| `mode` | Which mode produced the row: `search` or `detail`. |
| `input` | The input exactly as provided (keyword, BV id, av id or watch URL). |
| `source_type` | `search` for keyword rows, `detail` for a resolved video reference. |
| `source` | Normalized source: the keyword, or `BV…`/`av…` in detail mode. |
| `bvid` | Bilibili video id (BV string) — the row's unique key. |
| `aid` | Numeric video id (aid). |
| `url` | Canonical public watch URL: `https://www.bilibili.com/video/<bvid>`. |
| `title` | Video title, search-keyword markup stripped. |
| `description` | Video description as published upstream; null when upstream carries none. |
| `author` | Uploader display name. |
| `author_mid` | Uploader numeric uid (mid). |
| `published_at` | Publish time, ISO 8601 (upstream unix `pubdate`). |
| `duration_secs` | Duration in seconds (search rows parse the `MM:SS` display string). |
| `duration_text` | Duration as displayed upstream, e.g. `04:32` or `2398:14`. |
| `view_count` | View count. |
| `danmaku_count` | Danmaku (bullet-comment) count. |
| `like_count` | Like count. |
| `favorite_count` | Favorite count. |
| `reply_count` | Reply count. |
| `tags` | Upstream tag list; always an array (detail rows carry none, so `[]`). |
| `cover_url` | Cover image URL, https-normalized. |
| `error` | Free per-input error message; null on video rows. |
| `scraped_at` | Extraction timestamp. |

### Pricing

Pay per event, and **the platform usage is on us** — the price you see is the price you pay, with no compute bill on top.

| Event | Price | What one charge buys |
|---|---|---|
| Bilibili video row | **$0.01** | One delivered public Bilibili video row: title, watch URL, uploader, publish time, duration, views, danmaku, likes, favorites, replies, tags and cover URL. An empty keyword, a video reference that is not a Bilibili video, a video that no longer exists, and any blocked, 5xx or timeout fetch are free error rows and are never charged. |
| Actor Start | **$0.002** | One run, whatever it returns. |

Higher Apify subscription tiers pay less on every event (Silver −20%, Gold −35%).

### Notes

- `detail` mode accepts `https://www.bilibili.com/video/BV…`, `m.bilibili.com`
  watch URLs, bare BV ids (`BV1xx411c7mD`) and bare av ids (`av12345`).
  `b23.tv` short links are not resolved in v1 — they need an HTTP redirect the
  transport does not expose.
- Bilibili's risk control answers HTTP 412 (or a `-412` JSON envelope) for
  rate-limited IPs; the actor rotates its proxy session and retries, and a
  fetch that never succeeds is a free error row.
- Videos that no longer exist answer `-404` with HTTP 200 and are delivered as
  a free error row, never as an empty success.

# Actor input Schema

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

search: find public Bilibili videos by keyword. detail: resolve specific videos by BV id, av id or watch URL.

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

search mode: keywords to run against the public Bilibili video search (e.g. python, 音乐, machine learning). Up to 10 keywords per run, CJK included.

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

detail mode: Bilibili videos as watch URLs (https://www.bilibili.com/video/BV…), BV ids (BV1xx411c7mD) or av ids (av12345). Deduplicated and capped at 50 per run.

## `maxItemsPerKeyword` (type: `integer`):

Hard local cap on rows delivered per keyword (1-50; one search page answers with 20 results).

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

Proxy for the public Bilibili API surface. Datacenter is the validated default.

## Actor input object example

```json
{
  "mode": "search",
  "keywords": [
    "python",
    "machine learning",
    "编程"
  ],
  "videoUrls": [
    "https://www.bilibili.com/video/BV1YaeN6xEWR"
  ],
  "maxItemsPerKeyword": 20,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (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": [
        "python",
        "machine learning",
        "编程"
    ],
    "videoUrls": [
        "https://www.bilibili.com/video/BV1YaeN6xEWR"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("leorochasantos/bilibili-videos").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": [
        "python",
        "machine learning",
        "编程",
    ],
    "videoUrls": ["https://www.bilibili.com/video/BV1YaeN6xEWR"],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("leorochasantos/bilibili-videos").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": [
    "python",
    "machine learning",
    "编程"
  ],
  "videoUrls": [
    "https://www.bilibili.com/video/BV1YaeN6xEWR"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call leorochasantos/bilibili-videos --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,leorochasantos/bilibili-videos"
        }
    }
}
```

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/uK1YZH5ERsWm1ukrl/builds/xvWEGUQ8RwnUbBqRz/openapi.json
