# Douban Reviews Scraper — Book & Music Short Reviews (`jovial_leopardfrog/douban-reviews-scraper`) Actor

Scrape Douban book and music short reviews. Get star rating, review text, reviewer name and profile URL, date, helpful votes and permalink. Input: a Douban subject URL, ID pair, or numeric subject id. Output: clean JSON/CSV plus the subject title. HTTP-only, no login, no browser.

- **URL**: https://apify.com/jovial\_leopardfrog/douban-reviews-scraper.md
- **Developed by:** [老大 于](https://apify.com/jovial_leopardfrog) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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

## Douban Reviews Scraper — Book & Music Short Reviews

Scrape [Douban](https://www.douban.com) short reviews (短评) for books and albums — star rating, full review text, reviewer name and profile URL, publication date, "有用" (helpful) vote count and a direct permalink to each review.

No login, no cookies, no browser. One plain HTTP request returns 20 reviews.

### What you get

One row per review:

| Field | Example |
|---|---|
| `subjectName` | 小王子 |
| `subjectKind` / `subjectId` | book / 1084336 |
| `reviewId` | 10287387 |
| `rating` | 5 |
| `reviewBody` | 十几岁的时候渴慕着小王子，一天之间可以看四十四次日落… |
| `authorName` / `authorUrl` | 眠去 / https://www.douban.com/people/rebekah/ |
| `datePublished` | 2007-02-08 |
| `helpfulVotes` | 9282 |
| `reviewUrl` | https://book.douban.com/comment/10287387/ |

### Input

- **Subjects to scrape** — one per line. Any of these forms works:
  - `book/1084336` or `music/1401180`
  - `1084336` (a bare id is treated as a book)
  - `https://book.douban.com/subject/1084336/`
- **Max reviews / max pages per subject** — hard caps so a subject with 200,000 reviews cannot run away with your bill.
- **Delay between page requests** — raise it if you start seeing 403s.

### Review order

Douban's "sort by time" option returns **HTTP 403** to any request that is not carrying a logged-in cookie. Verified request by request:

```
?sort=new_score -> 200, 38,779 bytes, 20 reviews
?sort=time      -> 403, 11,749 bytes, 0 reviews
(no sort param) -> 200, 38,779 bytes, 20 reviews   <- identical to sort=new_score
```

This Actor therefore uses Douban's own default order (most-useful first) and does not send a sort parameter at all. There is no input field for it, because offering a switch that always fails would be worse than not offering one.

### Cost

Priced per delivered review (`review-scraped` event). Rows are pushed to the dataset **before** the charge is issued, so a failed run is never billed for data it did not deliver.

### How it is built

- `src/sites/douban.js` — everything site-specific: URL shape, target resolution, and **two independent parsers** (a `cheerio` DOM walk over `li.comment-item[data-cid]`, and a plain-regex path that ignores the DOM entirely).
- `src/engine.js` — paging, retries, de-duplication, per-page delivery. Site-agnostic.
- `test/local_run.js` — runs both parsers over the same live page and diffs them field by field. If the two paths ever disagree on author/date/rating/body, the test shouts before you ship.

Run it locally with no Apify account:

```bash
node test/local_run.js book/1084336
```

### Notes

- Douban publishes no aggregate star average on the short-review listing, so `rating` is per review only.
- Short reviews have no individual headline; `reviewBody` is the whole text.
- Dates are normalised with an explicit format matcher, never `new Date(string)` — that constructor parses locale-style strings at local midnight and shifts the day when converted to UTC.

# Actor input Schema

## `subjects` (type: `array`):

One subject per line. Accepts a full URL (https://book.douban.com/subject/1084336/), a kind/id pair (book/1084336 or music/1401180), or a bare numeric subject id (1084336, treated as a book).

## `maxReviewsPerSubject` (type: `integer`):

Stop after this many reviews per subject. Douban serves 20 reviews per page.

## `maxPagesPerSubject` (type: `integer`):

Hard cap on page requests per subject. Protects you from a runaway bill on subjects with tens of thousands of reviews.

## `requestDelayMs` (type: `integer`):

Politeness delay. Raise it if you hit rate limiting.

## `includeReviewBody` (type: `boolean`):

Uncheck to keep only ratings, authors and dates (smaller dataset).

## Actor input object example

```json
{
  "subjects": [
    "book/1084336"
  ],
  "maxReviewsPerSubject": 100,
  "maxPagesPerSubject": 10,
  "requestDelayMs": 1200,
  "includeReviewBody": true
}
```

# Actor output Schema

## `reviews` (type: `string`):

All scraped short reviews as dataset items: star rating, review text, reviewer name and profile URL, date, helpful votes and permalink, plus the subject title.

# 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 = {
    "subjects": [
        "book/1084336"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("jovial_leopardfrog/douban-reviews-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 = { "subjects": ["book/1084336"] }

# Run the Actor and wait for it to finish
run = client.actor("jovial_leopardfrog/douban-reviews-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 '{
  "subjects": [
    "book/1084336"
  ]
}' |
apify call jovial_leopardfrog/douban-reviews-scraper --silent --output-dataset

```

## MCP server setup

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