# Bilibili Scraper (`muhammad_noman_riaz/bilibili-scraper`) Actor

Scrape Bilibili videos by URL, user or search term: title, stats, tags, author, plus optional comments and danmaku. No login or cookies needed. Pay only for videos returned.

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

## Pricing

from $2.50 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Scraper

Scrape Bilibili (哔哩哔哩) videos without login or cookies. Give it video URLs, user space URLs or search keywords, and get one clean record per video: title, description, author, publish date, duration, views, likes, coins, favorites, shares, danmaku count, comment count, tags and thumbnail. Optionally add top comments and the full danmaku (bullet comment) feed with timestamps.

**You only pay for videos that are returned.** Videos that are removed, private, region-locked or still failing after all retries are skipped and not charged. They are listed in `FAILED_ITEMS` in the run's key-value store with the reason.

### What you can use it for

- Track views, likes, coins and favorites of Bilibili creators and videos over time
- Research trends on Bilibili by keyword
- Collect danmaku for audience sentiment and engagement analysis by timestamp
- Monitor a creator's newest uploads
- Build Chinese video datasets for research or LLM work

### Features

- **No login, no cookies:** uses Bilibili's public web APIs only
- **Three ways in:** video URLs (`/video/BV...` or `/video/av...`), user space URLs (`space.bilibili.com/<mid>`, newest videos first) and search terms
- **Stable English field names**, with ISO dates
- **Danmaku:** text and playback time in seconds for every bullet comment the public feed returns
- **Comments:** top comments with text, likes, date and author name
- **Retries on a fresh proxy IP** when Bilibili rate-limits (codes -412 and -352)
- **Duplicates removed:** a video found by several sources is scraped once

### Input

```json
{
  "startUrls": [
    { "url": "https://www.bilibili.com/video/BV17x411w7KC" },
    { "url": "https://space.bilibili.com/2" }
  ],
  "searchTerms": ["猫"],
  "maxItems": 20,
  "includeComments": true,
  "maxCommentsPerVideo": 20,
  "includeDanmaku": false
}
```

| Field | Description |
| --- | --- |
| `startUrls` | Video URLs and user space URLs |
| `searchTerms` | Keywords to search videos for |
| `maxItems` | Max videos per user URL and per search term (default 20) |
| `includeComments` | Add top comments to each video (default off) |
| `maxCommentsPerVideo` | Upper limit of comments per video (default 20) |
| `includeDanmaku` | Add danmaku to each video (default off) |
| `maxConcurrency` | Videos processed in parallel (default 5) |
| `maxRequestRetries` | Attempts per video or source, each on a new IP (default 6) |
| `proxy` | Proxy settings, residential recommended |

### Output

One item per video:

```json
{
  "bvid": "BV17x411w7KC",
  "aid": 170001,
  "title": "【MV】保加利亚妖王AZIS视频合辑",
  "description": "sina 保加利亚超级天王 Azis1999年出道...",
  "url": "https://www.bilibili.com/video/BV17x411w7KC",
  "duration": 2412,
  "publishedAt": "2011-11-09T14:55:33.000Z",
  "author": { "mid": 122541, "name": "冰封.虾子" },
  "stats": {
    "views": 45824141,
    "likes": 943259,
    "coins": 294996,
    "favorites": 876996,
    "shares": 43204192,
    "danmaku": 915678,
    "comments": 184148
  },
  "tags": ["保加利亚妖王", "保加利亚", "Азис", "azis", "mv"],
  "thumbnail": "https://i2.hdslb.com/bfs/archive/1ada8c32a9d168e4b2ee3e010f24789ba3353785.jpg",
  "category": null,
  "categoryId": 2017,
  "comments": [
    { "text": "妖王为了提倡节约用水...", "likes": 181172, "publishedAt": "2019-02-03T04:07:30.000Z", "authorName": "君之自由" }
  ],
  "danmaku": [
    { "text": "欢迎来到米奇妙妙屋", "timeSec": 3.848 }
  ]
}
```

`duration` and `timeSec` are in seconds. `comments` and `danmaku` appear only when you turn them on. `category` is the category name when Bilibili includes it in the response, which it often does not; `categoryId` is always filled.

### Limits

- **Comments:** without login, Bilibili only serves a few top comments per video, usually 3. This actor does not log in, so it cannot return more than Bilibili shows to a logged-out visitor.
- **Danmaku** come from Bilibili's public XML feed, which holds a capped sample (at most 1,800 lines per video in our tests), not every danmaku ever sent. For multi-part videos, only the first part is read.
- **User videos** are listed through Bilibili's public series endpoint, newest first.
- **Search** returns up to 20 results per page and follows Bilibili's default ranking.
- Short links (`b23.tv`), bangumi, live streams and articles are not supported.

### Privacy

The actor collects only public video data and, for comments, the commenter's public display name. It does not collect user IDs of commenters, the hashed sender IDs in the danmaku feed, emails or any private data.

### FAQ

**Do I need a Bilibili account?** No. Everything comes from public endpoints that work for logged-out visitors.

**Why did some videos fail?** Removed, private or region-locked videos cannot be scraped. Check `FAILED_ITEMS` in the key-value store. You are not charged for them.

**Which proxy should I use?** Bilibili rate-limits busy IPs. Residential proxies with a low `maxConcurrency` give the most stable runs.

# Actor input Schema

## `startUrls` (type: `array`):

Bilibili video URLs (https://www.bilibili.com/video/BV... or /video/av...) and user space URLs (https://space.bilibili.com/<mid>). For a user, the newest videos are scraped up to Max items.

## `searchTerms` (type: `array`):

Keywords to search Bilibili videos for. Each term returns up to Max items videos, in Bilibili's default search order.

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

Maximum number of videos to scrape for each user URL and each search term. Video URLs always return one item.

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

Adds top comments (text, likes, date, author name) to each video. Without login, Bilibili only shows a few top comments per video, usually 3.

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

Upper limit of comments to return per video when comments are included.

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

Adds the bullet comments (danmaku) shown over the video, with their playback time in seconds. Taken from the first part of multi-part videos.

## `maxConcurrency` (type: `integer`):

Maximum number of videos processed at the same time. Keep it low; Bilibili rate-limits fast clients.

## `maxRequestRetries` (type: `integer`):

How many times a video or source is tried, each time on a new proxy IP, before it is skipped.

## `proxy` (type: `object`):

Proxy used for requests. Residential proxies are recommended to avoid Bilibili rate limits.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.bilibili.com/video/BV17x411w7KC"
    }
  ],
  "searchTerms": [
    "猫"
  ],
  "maxItems": 20,
  "includeComments": false,
  "maxCommentsPerVideo": 20,
  "includeDanmaku": false,
  "maxConcurrency": 5,
  "maxRequestRetries": 6,
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `videos` (type: `string`):

One item per scraped Bilibili video with stats, tags and optional comments and danmaku

# 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 = {
    "startUrls": [
        {
            "url": "https://www.bilibili.com/video/BV17x411w7KC"
        }
    ],
    "searchTerms": [
        "猫"
    ],
    "proxy": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("muhammad_noman_riaz/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 = {
    "startUrls": [{ "url": "https://www.bilibili.com/video/BV17x411w7KC" }],
    "searchTerms": ["猫"],
    "proxy": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("muhammad_noman_riaz/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 '{
  "startUrls": [
    {
      "url": "https://www.bilibili.com/video/BV17x411w7KC"
    }
  ],
  "searchTerms": [
    "猫"
  ],
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call muhammad_noman_riaz/bilibili-scraper --silent --output-dataset

```

## MCP server setup

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