# Bilibili Scraper (哔哩哔哩) - Search, Videos, UP主, Comments (`zalize/bilibili-scraper`) Actor

Scrape Bilibili (哔哩哔哩 / B站) without login or cookies: keyword search, video details & stats (views, likes, coins, danmaku), UP主 profiles + uploads, comment threads, ranking boards (排行榜) and the popular feed (热门). Clean JSON/CSV/Excel. Free to use.

- **URL**: https://apify.com/zalize/bilibili-scraper.md
- **Developed by:** [ming peng](https://apify.com/zalize) (community)
- **Categories:**
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Bilibili Scraper (哔哩哔哩数据采集)

Extract public data from [Bilibili](https://www.bilibili.com), China's largest video community, as clean JSON — no login, cookies or browser needed.

**What you get**

| Mode | Input | Output |
| --- | --- | --- |
| Keyword search | `keywords` | Videos matching each keyword, sorted by relevance / views / newest / danmaku / favorites / comments |
| Video details | `videoUrls` (URL, `BV…` or `av…` ID) | Title, description, cover, duration, publish time, category, views, likes, coins, favorites, shares, comments, danmaku, owner, optional tags |
| Creator (UP主) | `userUrls` (space URL or UID) | Profile (followers, level, verification, total videos/likes) plus latest uploads |
| Comments | `includeComments: true` | Hot or newest comments (with up to 3 sub-replies each) for every collected video |
| Rankings & trending | `rankings` (all / tech / game / knowledge / … ), `popularCount` | Current ranking boards (排行榜) and the popular feed (热门), full video details for each entry |

Every dataset item carries a `type` field (`video`, `comment`, `user`) so mixed results are easy to filter.

### Example input

```json
{
    "keywords": ["大模型", "RAG 教程"],
    "searchOrder": "click",
    "maxVideosPerKeyword": 40,
    "userUrls": ["https://space.bilibili.com/946974"],
    "maxVideosPerUser": 20,
    "includeComments": true,
    "maxCommentsPerVideo": 20,
    "includeTags": true
}
```

### Example output (video)

```json
{
    "type": "video",
    "source": "search",
    "keyword": "大模型",
    "aid": 113684026232679,
    "bvid": "BV1uNk1YxEJQ",
    "url": "https://www.bilibili.com/video/BV1uNk1YxEJQ",
    "title": "【全748集】目前B站最全最细的AI大模型零基础全套教程…",
    "durationSeconds": 55907,
    "publishedAt": "2024-12-20T07:56:52+00:00",
    "stats": { "views": 3794355, "likes": 71230, "coins": 55480, "favorites": 240211, "shares": 30112, "comments": 5024, "danmaku": 16842 },
    "owner": { "mid": 3546578890230230, "name": "…", "url": "https://space.bilibili.com/3546578890230230" },
    "tags": ["Transformer", "AI大模型", "提示词工程"]
}
```

### Use cases

- Market & trend research on Chinese tech, gaming, anime and education content
- Influencer discovery: find UP主 by topic, compare followers and engagement
- Sentiment / feedback analysis from comment threads
- Building datasets for LLM / RAG pipelines in Chinese

### Pricing

The Actor itself is currently **free** — you only pay for Apify platform usage (compute), which is covered by the free plan for typical runs (a 200-item run costs about $0.01). Use `maxItems` to cap run size. If pay-per-result pricing is introduced later, existing users get 14 days' notice per Apify Store rules.

### Limitations & fair use

- Only public data is collected; there is no login, no cookies, and no bypassing of Bilibili's access controls.
- Requests are throttled (≈2 req/s with jitter) and retried with back-off when Bilibili rate-limits. Very large runs may be slower; enable Apify Proxy if you see many `HTTP 412` warnings.
- Some videos have comments disabled (`code 12002`); they are skipped with a warning.
- Please respect Bilibili's Terms of Service and applicable data-protection laws when using the output.

### Integrations

Run from Apify Console, schedule it, or call it via the [Apify API](https://docs.apify.com/api/v2) / [Python](https://docs.apify.com/api/client/python) / [JavaScript](https://docs.apify.com/api/client/js) clients and export to JSON, CSV, Excel or Google Sheets.

# Actor input Schema

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

Search Bilibili videos by keyword (Chinese or English). Each keyword returns up to *Max videos per keyword* results.

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

How search results are ranked.

## `maxVideosPerKeyword` (type: `integer`):

Upper limit of videos collected for each keyword (20 per page, max ~1000).

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

Direct video links, BV IDs (BV1GJ411x7h7) or av IDs (av170001). Full details and stats are returned for each.

## `userUrls` (type: `array`):

Creator space links (https://space.bilibili.com/946974) or numeric UIDs. Returns the profile plus their latest uploads.

## `maxVideosPerUser` (type: `integer`):

How many latest uploads to fetch for each creator (0 = profile only).

## `rankings` (type: `array`):

Fetch the current top-100 ranking for selected categories.

## `popularCount` (type: `integer`):

Number of videos to fetch from the current 'Popular' feed (0 = skip).

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

Also scrape top comments for every video found.

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

Comment limit for each video (top-level replies and up to 3 sub-replies each).

## `commentSort` (type: `string`):

Hot (most liked) or newest first.

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

Fetch the tag list for each video (one extra request per video).

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

Hard cap on the total number of dataset items (videos + comments + users) for this run. 0 = no cap.

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

Optional. Bilibili public endpoints work without a proxy; enable Apify Proxy only if you hit rate limits.

## Actor input object example

```json
{
  "keywords": [
    "大模型"
  ],
  "searchOrder": "totalrank",
  "maxVideosPerKeyword": 50,
  "videoUrls": [],
  "userUrls": [],
  "maxVideosPerUser": 30,
  "rankings": [],
  "popularCount": 0,
  "includeComments": false,
  "maxCommentsPerVideo": 20,
  "commentSort": "hot",
  "includeTags": false,
  "maxItems": 0,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# 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": [
        "大模型"
    ],
    "videoUrls": [],
    "userUrls": [],
    "rankings": [],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("zalize/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": ["大模型"],
    "videoUrls": [],
    "userUrls": [],
    "rankings": [],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("zalize/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": [
    "大模型"
  ],
  "videoUrls": [],
  "userUrls": [],
  "rankings": [],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call zalize/bilibili-scraper --silent --output-dataset

```

## MCP server setup

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