# Bilibili Video Scraper (哔哩哔哩) - Search, Popular & Video Stats (`qwixlab/bilibili-video-scraper`) Actor

Scrape Bilibili (B站) videos without login: keyword search, video URLs and the Popular feed. Views, likes, coins, favorites, danmaku, comments count, author and tags as flat rows. Pay only per video.

- **URL**: https://apify.com/qwixlab/bilibili-video-scraper.md
- **Developed by:** [QWIX Lab](https://apify.com/qwixlab) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.40 / 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/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 (哔哩哔哩 / B站)

Extract public video data from **Bilibili**, China's largest video community, without a login and without cookies of your own.

- **Keyword search** – up to 1,000 videos per keyword (Bilibili's own limit), sorted by relevance, views, date, danmaku or favorites.
- **Video URLs / IDs** – full stats for any public video (`BV…`, `av…` or a bilibili.com link).
- **Popular feed (热门)** – what is trending on Bilibili right now.

Every row is flat (no nested objects), so it opens directly in Excel, Google Sheets or any BI tool.

### What you can use it for

- Track Chinese-market trends, brands and competitors on Bilibili.
- Find creators (UP主) for a niche and compare their reach.
- Monitor views, likes, coins and favorites of selected videos over time (schedule the Actor).
- Build datasets for research on Chinese video content.

### Input

| Field | Type | Description |
|---|---|---|
| `searchQueries` | list of strings | Keywords, Chinese or English |
| `maxResultsPerQuery` | integer (1–1000, default 100) | Videos per keyword |
| `sortBy` | `totalrank` · `click` · `pubdate` · `dm` · `stow` | Relevance · most views · newest · most danmaku · most favorites |
| `includeFullStats` | boolean (default `false`) | Adds coins and shares to search results (one extra request per video) |
| `videoUrls` | list of strings | Video links or BV/av IDs |
| `includePopular` | boolean (default `false`) | Also scrape the Popular feed |
| `maxPopularVideos` | integer (default 100) | Videos taken from the Popular feed |
| `proxyConfiguration` | proxy | Apify Proxy recommended |

Example:

```json
{
    "searchQueries": ["咖啡", "python tutorial"],
    "maxResultsPerQuery": 100,
    "sortBy": "totalrank",
    "videoUrls": ["https://www.bilibili.com/video/BV1aiKVzoE7t/"],
    "includePopular": true,
    "maxPopularVideos": 50,
    "proxyConfiguration": { "useApifyProxy": true }
}
```

### Output

One row per video:

| Field | Description |
|---|---|
| `source` | `search`, `url` or `popular` |
| `query` | Keyword (or the URL you provided) |
| `rank` | Position in search results / Popular feed |
| `bvid`, `aid` | Bilibili video IDs |
| `url` | Video link |
| `title`, `description` | Title and description (search highlight tags removed) |
| `coverUrl` | Cover image |
| `durationSec` | Length in seconds |
| `publishedAt` | Publish time, ISO 8601 (UTC) |
| `authorName`, `authorMid`, `authorUrl` | Uploader (UP主) name, ID and channel link |
| `category`, `tags` | Category name and comma-separated tags (search results) |
| `views`, `likes`, `favorites`, `comments`, `danmaku` | Engagement counters |
| `coins`, `shares` | For URL and Popular rows always; for search rows when `includeFullStats` is on |
| `scrapedAt` | When the row was collected |

Example row (real data from a test run):

```json
{
    "source": "search",
    "query": "咖啡",
    "rank": 1,
    "bvid": "BV1aiKVzoE7t",
    "url": "https://www.bilibili.com/video/BV1aiKVzoE7t",
    "title": "【咖啡推荐】48天喝了上百杯咖啡，2025年度最新咖啡大测评！…",
    "durationSec": 553,
    "publishedAt": "2025-06-24T11:37:31.000Z",
    "authorName": "挑剔测评家",
    "authorUrl": "https://space.bilibili.com/3493116086585951",
    "category": "美食测评",
    "views": 504888,
    "likes": 13905,
    "favorites": 10218,
    "comments": 394,
    "danmaku": 366,
    "coins": null,
    "shares": null
}
```

See `sample_output.json` in the source for 20 complete rows.

### Pricing

Pay per result: **$3.40 per 1,000 videos** ($0.0034 per video). You pay only for videos saved to your dataset. Set "Maximum cost per run" and the Actor stops cleanly at your budget.

### Reliability

- Uses Bilibili's public web API, the same one the website uses for logged-out visitors.
- Automatic retries with exponential backoff; on rate-limit answers (-412, -352) it starts a fresh guest session and, with Apify Proxy, a new IP.
- A bad keyword or URL never fails the whole run: the Actor keeps everything it already collected and lists problems in the `FAILURES` record of the key-value store.

### FAQ

**Do I need a Bilibili account or cookies?** No. Only data that Bilibili shows to logged-out visitors is collected.

**Why at most 1,000 results per keyword?** Bilibili's search returns 50 pages of 20 results. Use several more specific keywords or different sort orders to get more.

**Does it scrape comments or danmaku?** Not yet. Bilibili shows only a few comments to logged-out visitors, so this Actor focuses on video data.

**Which proxy should I use?** Apify Proxy (automatic) works for most runs. If you see many retries in the log, switch to residential proxies.

**Is it legal?** The Actor collects only publicly available video data and no private user information. You are responsible for using the data in line with the laws that apply to you and Bilibili's terms.

# Actor input Schema

## `searchQueries` (type: `array`):

Keywords to search on Bilibili, one per line. Chinese or English. Each keyword returns up to the limit below (Bilibili shows at most 1,000 results per keyword).

## `maxResultsPerQuery` (type: `integer`):

How many videos to save for each keyword.

## `sortBy` (type: `string`):

Order of keyword search results.

## `includeFullStats` (type: `boolean`):

Search results already contain views, likes, favorites, comments and danmaku. Enable to also load coins and shares (one extra request per video, slower).

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

Bilibili video links (https://www.bilibili.com/video/BV...) or plain BV / av IDs. Returns full stats for each video.

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

Also save the current Bilibili Popular feed.

## `maxPopularVideos` (type: `integer`):

How many videos to take from the Popular feed.

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

Proxy servers used for requests. Apify Proxy is recommended; switch to residential if you see many retries.

## Actor input object example

```json
{
  "searchQueries": [
    "咖啡",
    "python tutorial"
  ],
  "maxResultsPerQuery": 100,
  "sortBy": "totalrank",
  "includeFullStats": false,
  "includePopular": false,
  "maxPopularVideos": 100,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

All scraped rows in the default dataset.

# 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 = {
    "searchQueries": [
        "咖啡",
        "python tutorial"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("qwixlab/bilibili-video-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 = {
    "searchQueries": [
        "咖啡",
        "python tutorial",
    ],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("qwixlab/bilibili-video-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 '{
  "searchQueries": [
    "咖啡",
    "python tutorial"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call qwixlab/bilibili-video-scraper --silent --output-dataset

```

## MCP server setup

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