Bilibili Comments
Pricing
$0.01 / 1,000 results
Bilibili Comments
Effortlessly extract comments and replies from any Bilibili video.
0.0 (0)
Pricing
$0.01 / 1,000 results
0
Total users
2
Monthly users
2
Runs succeeded
>99%
Last modified
2 days ago
Bilibili Comment Scraper
This Apify Actor allows you to scrape comments and replies from any Bilibili video. It's designed to be simple to use, handling the complexities of the Bilibili API for you. You can easily paginate through thousands of comments and replies across multiple Actor runs.
Features
- Two scraping modes: Scrape root-level comments or replies to a specific comment.
- Flexible video identifier: Use a video's URL, BVID, or AVID.
- Powerful pagination: Seamlessly continue scraping from where you left off in a previous run.
- Control scrape direction: Fetch comments from newest to oldest or oldest to newest.
- Simple and robust: Just provide the video and let the Actor handle the rest.
How to Use
The Actor operates in two modes: Comment Mode (default) and Reply Mode.
1. Scraping Root Comments
To get the main comments for a video, simply provide the video identifier.
- Set the
video
input field to the URL, BVID, or AVID of the Bilibili video. - Run the Actor.
- The results will appear in the Actor's dataset. Each item is a comment object from Bilibili, with an added
cursor
field for pagination. - To get the next batch of comments, find the last comment in your dataset. Copy the value of
cursor.next_offset
from it. - Run the Actor again with the same
video
input, but this time paste the copied value into theoffset
input field. - Repeat until
cursor.is_end
istrue
in the last comment of a run, which means all comments have been scraped.
2. Scraping Replies
To get replies for a specific comment, you first need its ID.
- Run the Actor in Comment Mode to get the root comments.
- In the dataset, find the comment for which you want to scrape replies. Note its
rpid
value. - Run the Actor again. This time, in addition to the
video
input, set theroot_comment_id
field to therpid
you just found. This will activate Reply Mode. - Pagination for replies works just like for root comments. Use the
cursor.next_offset
from the last reply in a dataset as theoffset
for the next run.
Input
The Actor's behavior is controlled by the following input fields:
Field | Type | Required | Description |
---|---|---|---|
video | String | Yes | Identifier for the Bilibili video. Can be a full URL (e.g., https://www.bilibili.com/video/BV1... ), a BVID (e.g., BV1Db411L7F5 ), or an AVID (e.g., av80682285 ). |
root_comment_id | Integer | No | The ID (rpid ) of a root comment. Providing this switches the Actor to Reply Mode to scrape its replies. |
limit | Integer | No | Maximum number of comments to return. Defaults to 20 , maximum 1000 . |
offset | Integer | No | The starting point for scraping. For subsequent runs, use the cursor.next_offset value from the last item of the previous run's dataset. |
direction | Integer | No | (Comment Mode only) The order in which to scrape comments. 1 for oldest to newest, 2 for newest to oldest. Defaults to 2 . |
Example Input
Scraping root comments (first run):
{"video": "BV1Db411L7F5","limit": 100}
Scraping replies for comment with ID 6013353598
:
{"video": "BV1Db411L7F5","root_comment_id": 6013353598,"limit": 60}
Paginating (continuing a previous run):
{"video": "BV1Db411L7F5","limit": 100,"offset": 20}
Output
The Actor stores its results in the default dataset. Each item in the dataset is a JSON object representing a single comment or reply, with an added cursor
object containing metadata about the scraping process.
Example Output Item
{"rpid": 6013353598,"oid": 80682285,"type": 1,"mid": 17924040,"root": 0,"parent": 0,"like": 1234,"member": {"mid": "17924040","uname": "some_user","sex": "保密"},"content": {"message": "This is a comment."},"replies": null,"cursor": {"batch_number": 0,"is_begin": true,"is_end": false,"next_offset": 20,"all_count": 5000}}
Note: The fields in the main object (like rpid
, member
, content
, etc.) come directly from the Bilibili API and are subject to change.
The cursor
Object
This object is attached to every comment and provides context for pagination.
Field | Type | Description |
---|---|---|
next_offset | Integer | The most important field. Use this as the offset in your next run to get the next page of results. |
is_end | Boolean | If true , you have reached the last page of comments/replies in the current direction. |
max_offset | Integer | (Comment Mode only) Total number of root comments for the video. Note that offset numbers are not always consecutive. |
total_count | Integer | (Reply Mode only) Total number of replies for the comment. |
is_begin | Boolean | If true , this is the first page of results. |
batch_number | Integer | The batch number of the current request (starts at 0). |