# Bilibili Scraper - Trending, Video Stats & Danmaku (`apricot_blackberry/bilibili-scraper`) Actor

Mine Bilibili (哔哩哔哩) like nobody else can: trending videos, full stats, and the danmaku comment stream that no Western tool bothers to extract. Cookie-free, straight off the public API, agent-ready output.

- **URL**: https://apify.com/apricot\_blackberry/bilibili-scraper.md
- **Developed by:** [Creator Fusion](https://apify.com/apricot_blackberry) (community)
- **Categories:** Social media, Videos, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $6.00 / 1,000 video details

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?

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 — Trending, Video Stats & Danmaku

**Cookie-free Bilibili / 哔哩哔哩 scraper.** Two modes plus the one dataset nobody else in the West has:

1. **Trending feed** — pull Bilibili's popular/trending videos. No input, no login. Great for China trend spotting, KOL discovery, and content research.
2. **Video details** — paste video URLs or BVIDs and get the full stat block: views, likes, coins, favorites, shares, replies, **danmaku count**, category, duration, publish date, and UP creator info.
3. **Danmaku (弹幕)** — optionally pull the on-screen scrolling comment stream for each video: comment text, its timestamp in the video, and when it was sent. This behavioral signal is unique to Bilibili and doesn't exist on any Western platform.

No account, no session cookie, no CAPTCHA. Clean typed JSON, one dataset per run.

### Quick start

Trending feed (just press Start):

```json
{}
```

Video details + danmaku:

```json
{ "videoUrls": ["https://www.bilibili.com/video/BV1oyhM6AETw"], "includeDanmaku": true }
```

### Output (by rowType)

- **trending / video**: `bvid`, `title`, `desc`, `url`, `category`, `durationSec`, `publishedAt`, `views`, `likes`, `coins`, `favorites`, `shares`, `replies`, `danmakuCount`, `upName`, `upMid`, `cover`.
- **danmaku**: `bvid`, `text`, `videoTimeSec` (position in the video), `sentAt`.

### Why this one

- **Cookie-free** — pure public-API extraction, no login token to paste.
- **Danmaku included** — the scrolling-comment stream is real audience-reaction data most scrapers skip.
- **Agent-ready** — every row carries a `rowType` discriminator and there's a machine-readable SUMMARY in the key-value store.
- **Self-healing** — requests go direct first (free); on a rate-limit or failure the Actor automatically retries through Apify residential proxy with a fresh rotating session before giving up, so proxy is billed to you only when it's actually needed.

***

### 中文说明（B站数据采集）

**无需登录 Cookie 的哔哩哔哩采集工具：**

1. **热门视频** — 拉取 B 站热门/排行视频，无需任何输入。适合国内趋势洞察、UP 主发现、内容选题。
2. **视频详情** — 粘贴视频链接或 BV 号，获取播放量、点赞、投币、收藏、分享、评论、弹幕数、分区、时长、发布时间及 UP 主信息。
3. **弹幕采集** — 可选提取每个视频的弹幕流（弹幕内容、出现的视频时间点、发送时间），这是 B 站独有的观众反应数据。

无需账号、无需 Cookie、无需验证码。

```json
{ "videoUrls": ["https://www.bilibili.com/video/BVxxxxxxxxxx"], "includeDanmaku": true }
```

Apify 平台在中国大陆及台湾地区可正常访问，每月 $5 免费额度，无需信用卡即可试用。

***

### For AI agents

```bash
curl -X POST "https://api.apify.com/v2/acts/apricot_blackberry~bilibili-scraper/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" -d '{}'
```

Empty input returns the trending feed (never an error), so speculative agent calls always get data. Filter on `rowType` (`trending` / `video` / `danmaku`).

### Honest limits

- **Keyword search** and **UP-creator video catalogs** require Bilibili's `wbi` request signing and are not in this cookie-free version (trending + by-id video details + danmaku are).
- Very old or removed videos return a not-found row in the SUMMARY, not the dataset.

# Actor input Schema

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

What to scrape. Auto-detected: video URLs/BVIDs -> video details; nothing -> trending feed.

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

Bilibili video URLs, e.g. https://www.bilibili.com/video/BV1oyhM6AETw

## `bvids` (type: `array`):

Bare Bilibili BV ids (alternative to URLs), e.g. BV1oyhM6AETw

## `includeDanmaku` (type: `boolean`):

Also extract the danmaku comment stream for each video (text, video timestamp, sent time). This is the on-screen scrolling comments unique to Bilibili.

## `maxDanmakuPerVideo` (type: `integer`):

Cap on danmaku rows per video when danmaku is enabled.

## `page` (type: `integer`):

Page of the trending feed to start from (20 videos per page).

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

Cap on videos per run.

## `delayBetweenRequests` (type: `integer`):

Pause between API calls.

## `navigationTimeoutMs` (type: `integer`):

Per-request timeout in milliseconds.

## `maxProxyRetries` (type: `integer`):

If a direct request fails or is rate-limited, the Actor retries through Apify residential proxy with a fresh rotating session, up to this many times, before giving up. Set 0 to disable proxy fallback.

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

Self-healing: requests go DIRECT first (free), and only if one fails or is rate-limited does the Actor fall back to Apify residential proxy with a fresh rotating session — so you pay for proxy ONLY when it's needed to rescue a run. Set your own proxy here to override. Proxy data is billed to your Apify account.

## Actor input object example

```json
{
  "videoUrls": [],
  "bvids": [],
  "includeDanmaku": false,
  "maxDanmakuPerVideo": 1000,
  "page": 1,
  "maxItems": 100,
  "delayBetweenRequests": 600,
  "navigationTimeoutMs": 25000,
  "maxProxyRetries": 3
}
```

# 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 = {
    "videoUrls": [],
    "bvids": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("apricot_blackberry/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 = {
    "videoUrls": [],
    "bvids": [],
}

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

```

## MCP server setup

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