# Bilibili Video Search Scraper (`fetch_cat/bilibili-video-search-scraper`) Actor

Export public Bilibili video search results and video metadata with authors, thumbnails, engagement counts, tags, and publish dates.

- **URL**: https://apify.com/fetch\_cat/bilibili-video-search-scraper.md
- **Developed by:** [Hanna Nosova](https://apify.com/fetch_cat) (community)
- **Categories:** Social media, Videos, Marketing
- **Stats:** 2 total users, 1 monthly users, 96.7% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.02 / 1,000 item extracteds

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/platform/actors/running/actors-in-store#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 Video Search Scraper

Export public Bilibili video search results and BVID metadata for research, marketing analysis, creator discovery, and video trend monitoring. The actor saves structured video records with titles, URLs, authors, publish dates, thumbnails, categories, tags, and engagement metrics such as views, danmaku, likes, favorites, coins, shares, and replies.

Bilibili is a major Chinese video platform with communities around animation, games, music, education, technology, and creator content. This scraper helps turn public Bilibili video search pages and known video IDs into clean datasets that can be filtered, joined, exported, and consumed by downstream workflows.

### What it does

- Searches Bilibili videos by one or more keywords.
- Fetches direct video metadata from BVIDs or Bilibili video URLs.
- Optionally enriches results with detail and tag endpoints.
- Deduplicates videos across keywords/pages.
- Saves tabular video records to the default dataset.
- Writes a `RUN_SUMMARY` key-value record with saved item count and partial-failure details.
- Stops safely near the configured run time limit.

### Who is it for

This actor is useful for analysts, agencies, researchers, and data teams that need public Bilibili video metadata without manually copying search results. Typical users include:

- Social media analysts tracking creator or topic performance.
- Marketing teams researching Chinese video trends.
- Creator discovery teams building prospect lists.
- Academic researchers sampling public video metadata.
- SEO and content teams comparing titles, categories, tags, and engagement.
- Data engineers feeding Bilibili records into BI dashboards or enrichment pipelines.

### Input options

You can scrape by keyword, by direct BVID/video URL, or by combining both modes in one run.

- `keywords` - search terms to query on Bilibili video search.
- `bvids` - direct Bilibili BVIDs or video URLs.
- `maxItems` - maximum videos to save across all input modes.
- `sort` - Bilibili search ordering such as relevance, newest, views, danmaku, or favorites.
- `maxPagesPerKeyword` - maximum search result pages per keyword.
- `includeDetails` - fetch extra detail and tag metadata when available.
- `requestDelayMillis` - delay between requests to reduce rate limiting.
- `maxRequestRetries` - retries for transient Bilibili request failures.
- `runTimeSecs` - soft runtime deadline.
- `proxyConfiguration` - optional Apify Proxy settings.

### Input recipes

These example inputs can be copied into the Apify Console, API client, or CLI. Start with a small `maxItems` value while you validate your keyword, then increase it for larger exports.

### Examples

#### Search one keyword

```json
{
  "keywords": ["anime music"],
  "maxItems": 10,
  "maxPagesPerKeyword": 1,
  "includeDetails": true
}
```

#### Search multiple keywords

```json
{
  "keywords": ["travel vlog", "game review", "study with me"],
  "maxItems": 50,
  "maxPagesPerKeyword": 2,
  "sort": "pubdate"
}
```

#### Fetch direct video URLs or BVIDs

```json
{
  "bvids": ["BV1xx411c7mD"],
  "maxItems": 5,
  "includeDetails": true
}
```

#### Quick health-check run

```json
{
  "bvids": ["BV1xx411c7mD"],
  "maxItems": 1,
  "includeDetails": false,
  "requestDelayMillis": 0,
  "runTimeSecs": 60
}
```

### API usage

You can run the actor through the Apify API by sending the same JSON input shown in the examples. After the run succeeds, download the default dataset as JSON, CSV, Excel, or through the dataset API.

#### Node.js

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('fetch_cat/bilibili-video-search-scraper').call({
  keywords: ['anime music'],
  maxItems: 10,
  maxPagesPerKeyword: 1,
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

#### Python

```python
from apify_client import ApifyClient
import os

client = ApifyClient(os.environ['APIFY_TOKEN'])
run = client.actor('fetch_cat/bilibili-video-search-scraper').call(run_input={
    'keywords': ['anime music'],
    'maxItems': 10,
    'maxPagesPerKeyword': 1,
})

items = client.dataset(run['defaultDatasetId']).list_items().items
print(items)
```

#### cURL

```bash
curl -X POST "https://api.apify.com/v2/acts/fetch_cat~bilibili-video-search-scraper/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"keywords":["anime music"],"maxItems":10,"maxPagesPerKeyword":1}'
```

### Output fields

Each dataset item represents one Bilibili video. Common fields include:

- `keyword` - search keyword that found the result.
- `rank` - result rank within the keyword.
- `page` - search result page.
- `sort` - search sort used for the item.
- `sourceType` - `search` or `direct`.
- `title` - video title.
- `bvid` and `aid` - Bilibili video identifiers.
- `url` - canonical video URL.
- `author`, `mid`, and `authorAvatarUrl` - creator details.
- `description` - public video description when available.
- `publishedAt` and `publishTimestamp` - publish date values.
- `thumbnailUrl` - cover image URL.
- `category` and `parentCategory` - Bilibili category labels.
- `durationSeconds` and `durationText` - video duration.
- `viewCount`, `danmakuCount`, `likeCount`, `coinCount`, `favoriteCount`, `shareCount`, and `replyCount` - engagement metrics.
- `tags` - video tags when detail enrichment is enabled.
- `pages` - multi-part video page data when available.
- `scrapedAt` - extraction timestamp.

### Cost and limits

The actor uses pay-per-event pricing: a small start charge plus one item charge for each saved video. Use `maxItems`, `maxPagesPerKeyword`, and `runTimeSecs` to keep runs bounded.

For quick tests, set `maxItems` to 1-10 and keep `maxPagesPerKeyword` at 1. For larger exports, increase limits gradually and review the output quality before running broad keyword batches.

### MCP

You can use this actor from MCP-compatible assistants through the Apify MCP server. After connecting the server, ask your assistant to run `fetch_cat/bilibili-video-search-scraper` with a JSON input and then inspect the default dataset.

#### Claude Desktop / Claude Code setup

```bash
claude mcp add apify -- npx -y @apify/actors-mcp-server --actors fetch_cat/bilibili-video-search-scraper
```

If your MCP client uses JSON configuration, add an Apify server entry similar to this and provide your Apify token through the environment:

```json
{
  "mcpServers": {
    "apify": {
      "command": "npx",
      "args": [
        "-y",
        "@apify/actors-mcp-server",
        "--actors",
        "fetch_cat/bilibili-video-search-scraper"
      ],
      "env": {
        "APIFY_TOKEN": "YOUR_APIFY_TOKEN"
      }
    }
  }
}
```

#### Example prompts showing MCP usage

Prompt: "Run the Bilibili Video Search Scraper for `anime music`, save 10 videos, and summarize the top authors."

Prompt: "Fetch metadata for BVID `BV1xx411c7mD` and return the title, author, URL, views, and publish date."

Prompt: "Compare Bilibili search results for `travel vlog` and `study with me` using maxItems 20."

The dataset is the main output for automation workflows, while `RUN_SUMMARY` is useful for checking whether a run completed fully or partially.

### Tips for reliable runs

- Use specific keywords for better Bilibili search relevance.
- Keep `includeDetails` enabled when you need tags and full engagement statistics.
- Disable `includeDetails` for faster broad search sampling.
- Lower `maxPagesPerKeyword` for quick checks and raise it only after the query works.
- Use direct BVID input when you already know the videos to inspect.
- Add a request delay if Bilibili starts rate-limiting requests.
- Consider Apify Proxy configuration if direct requests are unreliable from your location.

### Legality and responsible use

This actor is designed for public Bilibili video metadata. It does not log into Bilibili, bypass access controls, or collect private account data. You are responsible for using the output in a lawful way, respecting Bilibili's terms, applicable privacy rules, and any restrictions that apply to your use case.

Do not use scraped data for spam, harassment, credential collection, or any activity that violates platform rules or applicable law. If you are unsure whether your use case is allowed, consult your legal or compliance team before running large exports.

### FAQ

#### Why did my run save no items?

The keyword may have no public video results, the BVID may be unavailable, or Bilibili may be temporarily rate-limiting requests. Try a known BVID, lower request volume, or retry later.

#### Can I scrape comments?

This actor focuses on video search results and video metadata. Comment extraction is not included in this actor.

#### Can I search by creator?

Use Bilibili keywords that include the creator name or provide known BVIDs. Dedicated creator-profile crawling is outside this actor's current scope.

#### Why are some fields null?

Bilibili does not return every field for every video or endpoint. Search results may include less detail than direct video metadata, and private/deleted/restricted videos may not expose full details.

### Related actors

Use this actor alongside other video, social media, and creator-discovery scrapers when building cross-platform trend reports. Related workflows often combine Bilibili data with YouTube, TikTok, Instagram, Google Trends, or general web search exports.

### Support

If you need a missing field or a run does not match the documented behavior, open an issue from the actor page and include the run ID and input. Include whether the problem happened with keyword search, direct BVID mode, or detail enrichment so it can be reproduced quickly.

# Actor input Schema

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

Bilibili video search keywords to scrape.

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

Optional Bilibili BVIDs or video URLs to fetch directly.

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

Maximum number of videos to save.

## `sort` (type: `string`):

Bilibili search ordering.

## `maxPagesPerKeyword` (type: `integer`):

Maximum search result pages to request for each keyword.

## `includeDetails` (type: `boolean`):

Fetch detail and tag endpoints for richer metadata when possible.

## `requestDelayMillis` (type: `integer`):

Delay between requests to reduce rate limiting.

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

Retries per Bilibili API request for transient errors.

## `runTimeSecs` (type: `integer`):

Soft processing deadline. The actor stops before the platform timeout.

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

Optional Apify Proxy configuration. Leave empty to use direct requests.

## Actor input object example

```json
{
  "keywords": [],
  "bvids": [
    "BV1xx411c7mD"
  ],
  "maxItems": 10,
  "sort": "totalrank",
  "maxPagesPerKeyword": 1,
  "includeDetails": true,
  "requestDelayMillis": 300,
  "maxRequestRetries": 2,
  "runTimeSecs": 60,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

## `runSummary` (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": [],
    "bvids": [
        "BV1xx411c7mD"
    ],
    "maxItems": 10,
    "sort": "totalrank",
    "maxPagesPerKeyword": 1,
    "includeDetails": true,
    "requestDelayMillis": 300,
    "maxRequestRetries": 2,
    "runTimeSecs": 60
};

// Run the Actor and wait for it to finish
const run = await client.actor("fetch_cat/bilibili-video-search-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": [],
    "bvids": ["BV1xx411c7mD"],
    "maxItems": 10,
    "sort": "totalrank",
    "maxPagesPerKeyword": 1,
    "includeDetails": True,
    "requestDelayMillis": 300,
    "maxRequestRetries": 2,
    "runTimeSecs": 60,
}

# Run the Actor and wait for it to finish
run = client.actor("fetch_cat/bilibili-video-search-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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": [],
  "bvids": [
    "BV1xx411c7mD"
  ],
  "maxItems": 10,
  "sort": "totalrank",
  "maxPagesPerKeyword": 1,
  "includeDetails": true,
  "requestDelayMillis": 300,
  "maxRequestRetries": 2,
  "runTimeSecs": 60
}' |
apify call fetch_cat/bilibili-video-search-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=fetch_cat/bilibili-video-search-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/ze2tM9CTDJDN6s0zk/builds/NbI7g29hqPOkyIIwC/openapi.json
