Bilibili Scraper 哔哩哔哩 B站 - Videos, Trending, UP主 (No Login)
Under maintenancePricing
from $2.00 / 1,000 videos
Bilibili Scraper 哔哩哔哩 B站 - Videos, Trending, UP主 (No Login)
Under maintenanceScrape Bilibili (B站) by keyword, video URL/BV ID, trending board or creator ID. Views, likes, coins, favorites, danmaku, tags, author. No cookies or login. $2 per 1,000 videos.
Pricing
from $2.00 / 1,000 videos
Rating
0.0
(0)
Developer
Lixiang Zhang
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
19 days ago
Last modified
Categories
Features
Share
Bilibili public metadata
Bilibili Scraper collects public video metadata from Bilibili (哔哩哔哩 / B站): keyword results, individual video details, the general popular board and profiles for known creator IDs. Use the JSON output to build a research list or supply source records to a developer or Agent workflow. It does not download videos or return comment text.
You do not need to supply a Bilibili account or login cookies. The Actor manages guest cookies internally. Running it in Console or through the token-based API requires an Apify account.
Price: $0.002 per returned video or creator profile ($2 per 1,000 results), including platform usage for the run. Check the Pricing tab before a paid run. Result counts and field availability depend on Bilibili's response.
Try the Python analysis example offline
The companion repository turns a Bilibili-format JSON array into video, creator-summary and review tables. It uses clearly marked synthetic data by default: no account, token or paid collection is needed to try the analysis.
https://github.com/lexang/bilibili-data-analysis
Download the repository and run these commands from its directory with Python 3.10 or later:
python analyze.pypython -m unittest -v test_example
CSV export uses the standard library. Excel export is optional. The fixture is fabricated, not a real Bilibili sample, and its outputs contain no real video or profile links. Import an export you are allowed to process with python analyze.py --input path/to/videos.json --output-dir my-analysis. Existing output directories are not overwritten.
Start with one keyword
- Open the existing keyword example task below, or paste the JSON into this Actor's input.
- Review the price and set a run charge limit before starting. For this small example, use 256 MB of memory, a 120-second run timeout and a $0.10 maximum total charge.
- Inspect the run status, logs and actual dataset rows. Export all fields as JSON, CSV or XLSX; the
overviewtable displays only a subset.
机械键盘 means mechanical keyboards. This input requests up to 20 relevance-ranked videos, with other collection modes and detail enrichment off:
{"searchKeywords": ["机械键盘"],"maxResultsPerKeyword": 20,"searchOrder": "totalrank","enrichSearchResults": false,"videoUrls": [],"includePopular": false,"maxPopular": 50,"creatorIds": [],"proxyConfiguration": {"useApifyProxy": false}}
This keyword/relevance setup has an existing 20-video author test. That test is not customer usage, a whole-platform ranking or evidence of demand. The walkthrough is separate from the synthetic GitHub fixture:
https://lexang.hashnode.dev/sorting-bilibili-videos-with-python-a-20-result-keyboard-research-sample
Input options
| Field | Behavior |
|---|---|
searchKeywords | Keyword video search; Chinese or English terms are accepted. |
maxResultsPerKeyword | Per-keyword cap, not a whole-run cap. Default 50; input range 1–1,000. Search stops after at most 50 pages and may return fewer rows. |
searchOrder | totalrank: relevance; click: views; pubdate: newest; dm: danmaku count; stow: favorites. “Newest” still means keyword results, not all new uploads. |
enrichSearchResults | Adds one detail request per search video and merges available non-null detail fields. Slower; no extra output row for enrichment. It does not add a complete tag list. |
videoUrls | Public video URLs, BV IDs or references such as av123456. Invalid references produce no video row and are recorded as errors in RUN_REPORT. |
includePopular, maxPopular | The 综合热门 general popular feed, not hot-search terms or a keyword-filtered ranking. Off by default; count defaults to 50, input range 1–500. |
creatorIds | Known numeric creator IDs or space.bilibili.com profile URLs. Returns profile fields, not name search or a full upload history. UP主 means a Bilibili creator. |
proxyConfiguration | Proxy is off in the example. It may help with IP blocks, but is not a guarantee of access; assess configuration and applicable costs before enabling it. |
Provide at least one keyword, video reference, creator ID or the popular-feed option. When several modes are enabled, the Actor processes keyword results, video references, the popular feed, then creator profiles. Rows can repeat across keywords or modes; deduplicate by BV ID before analysis. The published small example validates keyword/relevance search only, not every option above.
Output fields and missing values
| Video fields | Meaning and availability |
|---|---|
type, source, searchKeyword | type is video; source is search, detail or popular. searchKeyword is present for search rows. Enrichment keeps the search source. |
bvid, aid, url, title | Video identifiers, source link and title. |
authorMid, authorName | Creator ID and display name; use the ID for grouping. |
views, likes, favorites, comments, danmaku | Available counts, not unique viewers, sales, comment text or danmaku text. Fields can be null. |
coins, shares | Null in search-only rows. Detail requests can supply them when Bilibili returns values. |
publishedAt, durationSec, category | Publication time with +08:00 offset, duration in seconds and category. |
description, coverUrl, tags | Available text, cover URL and search tags. Detail/popular rows have tags: null; enrichment retains search tags rather than fetching a full tag list. |
pages, ipRegion | Detail/popular fields when available; pages is a part count, not downloaded video pages. |
Creator rows have type: "creator", mid, url, name, sign, avatarUrl, sex, level, verified, followers, following, videoCount and likesReceived. verified contains verification text or null, not a boolean. A search row's creator ID does not mean its profile was fetched. Creator fields and other collection modes have not been newly tested for this documentation update.
Treat null, absent values and empty search-tag arrays as incomplete information. Missing is not zero. A successful run can still have partial results or enrichment warnings; check the logs and coverage before comparing videos or creators. An observed sample sum is not a creator's total reach or a conversion rate.
Run status and error report
The updated build saves RUN_REPORT in the run's default key-value store, separately from the result dataset. Collection errors make the run fail, even if earlier rows were saved; those rows remain available. A detail-enrichment error preserves the search row and records a warning. A normal search with no matches is not treated as a collection failure.
Check outcome, errors, warnings and chargeLimitReached before using an export. partial means enrichment warnings; charge_limited means the SDK reported that the charge limit was reached and later work was stopped. Neither means every requested result or field was obtained. videoPushCalls and creatorPushCalls count completed SDK push calls, not delivered rows or charges; inspect the actual dataset. Invalid video references are reported as errors and later valid inputs can still be processed. A failed run must not be automatically restarted: it may already contain chargeable results.
Issue entries contain operation names, zero-based positions in the normalized input lists and numeric upstream error codes, without the complete input or exception text. Each error or warning list keeps at most 100 entries and reports omitted counts. Cancellation, forced termination or storage failure can prevent the report from being saved. This behavior has been tested with synthetic collection responses and the real SDK, not newly collected Bilibili data. Examples pinned to 0.1.4 below continue to use that older build and do not gain the report automatically.
Python and JavaScript API examples
Both examples default to printing a plan without contacting Apify. The paid paths have been checked with simulated responses only; updating this README did not start a new run.
The plan pins build 0.1.4, requests at most 20 keyword results, sets memory=256, timeout=120, maxTotalChargeUsd=0.10, restartOnError=false and waitForFinish=60. Exactly 20 returned videos at the listed price cost $0.04; the $0.10 charge cap is a ceiling, not the expected bill. Account-specific dataset reads, storage or transfer may have separate implications outside the run.
Python
Use the repository's api_example.py from the same directory. This code only prints the plan:
import jsonfrom api_example import make_planplan = make_plan(keyword="机械键盘", max_results=20, max_charge="0.10")print(json.dumps(plan, ensure_ascii=False, indent=2))
The script's default command is python api_example.py. Its real-run path requires your own APIFY_TOKEN environment variable, --allow-paid-run and --confirm-unit-price-usd 0.002. Enable it only after checking the current price, data permissions and budget. It records the run state locally, sends one POST, and fetches up to 20 dataset rows only if the response says SUCCEEDED.
JavaScript
Save this as a local .mjs file and use Node.js 20 or later. By default it prints the plan. A paid run requires all three environment settings: ALLOW_PAID_RUN=yes, CONFIRM_UNIT_PRICE_USD=0.002 and your own APIFY_TOKEN. Keep tokens out of URLs, source files and shared logs.
const actorId = 'qEqOp9akBbapIrsdj';const input = {searchKeywords: ['机械键盘'], maxResultsPerKeyword: 20,searchOrder: 'totalrank', enrichSearchResults: false,videoUrls: [], includePopular: false, maxPopular: 50,creatorIds: [], proxyConfiguration: { useApifyProxy: false },};const params = new URLSearchParams({build: '0.1.4', memory: '256', timeout: '120',maxTotalChargeUsd: '0.10', restartOnError: 'false', waitForFinish: '60',});const url = `https://api.apify.com/v2/actors/${actorId}/runs?${params}`;async function requestJson(method, endpoint, token, body) {const response = await fetch(endpoint, {method, redirect: 'error', signal: AbortSignal.timeout(75000),headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },...(body === undefined ? {} : { body: JSON.stringify(body) }),});if (!response.ok) throw new Error(`HTTP ${response.status}`);return response.json();}if (process.env.ALLOW_PAID_RUN !== 'yes') {console.log(JSON.stringify({ method: 'POST', url, input }, null, 2));} else {const token = process.env.APIFY_TOKEN?.trim();if (process.env.CONFIRM_UNIT_PRICE_USD !== '0.002' || !token) {throw new Error('请先核查价格并设置费用确认与自己的APIFY_TOKEN。');}let stage = 'start';try {const { data: run } = await requestJson('POST', url, token, input);if (run?.actId !== actorId || !/^[A-Za-z0-9]+$/.test(run?.id ?? '')) {throw new Error('运行响应异常。');}stage = 'read';console.log(JSON.stringify({ runId: run.id, status: run.status }));if (run.status === 'SUCCEEDED') {if (!/^[A-Za-z0-9]+$/.test(run.defaultDatasetId ?? '')) {throw new Error('数据集ID异常。');}const endpoint = `https://api.apify.com/v2/datasets/${run.defaultDatasetId}/items?format=json&offset=0&limit=20&clean=false`;const items = await requestJson('GET', endpoint, token);if (!Array.isArray(items) || items.length > 20 ||items.some(row => !row || typeof row !== 'object' || Array.isArray(row))) {throw new Error('数据集格式或数量异常。');}console.log(JSON.stringify(items, null, 2));}} catch {console.error(stage === 'start'? '启动响应不明;运行可能已启动。先检查Console,不要再次POST。': '运行已返回;检查Console中的状态及数据集,不要重启。');process.exitCode = 1;}}
Neither example polls, schedules, retries the POST or automatically aborts a run. Save the returned run ID locally. If the status is active or failed, inspect that run in Console instead of starting another. If the POST times out or its response is unclear, a cloud run may already exist. A local HTTP timeout does not stop it. Dataset retrieval is a separate GET and does not start another collection. SUCCEEDED does not guarantee 20 rows or complete fields.
Official API parameters and export formats:
https://docs.apify.com/api/v2/actors-runs-post.md
https://docs.apify.com/api/v2/dataset-items-get.md
Limits and support
- Public metadata only: no video files, subtitles, comment bodies, danmaku text, private material or member-only access. No captcha bypass.
- Bilibili can block requests or change its APIs. The client delays requests and retries some errors, including
-412and-352; results and speed are not guaranteed. Start small rather than assuming a proxy or a larger timeout will solve every block. - To report a problem in this Actor's Issues tab, include the non-secret input, run ID and relevant error message. Do not include login cookies or tokens.
- Public visibility does not grant redistribution, commercial-use or AI-training rights. Check Bilibili's terms, applicable law and your intended use before collecting or sharing data. Review source context before using metadata in an LLM workflow.
中文说明
本 Actor 获取 B站公开视频元数据:关键词搜索、指定视频详情、综合热门及已知 UP主 ID 的主页资料。每条视频或主页资料 $0.002,即每千条 $2。无需提供 B站账号登录 Cookie;程序内部使用访客 Cookie,常规调用仍需 Apify 账号。评论、弹幕字段是数量,不是正文;不下载视频、字幕或非公开内容。搜索数据中的投币与分享数可能为空,详情补全不会补全标签列表。先用 GitHub 合成数据离线体验分析,再决定是否付费采集;当前小样本验证不覆盖所有模式。