# Dangdang Scraper (China's largest bookstore) (`crawlerbros/dangdang-scraper`) Actor

Scrape dangdang.com - Chinese books e-commerce. Search by keyword, browse book categories, or fetch product details. Emits title, author, publisher, prices, discount, rating, review count and cover images.

- **URL**: https://apify.com/crawlerbros/dangdang-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Categories:** Automation, E-commerce, Integrations
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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

## Dangdang Scraper

Scrape [dangdang.com](https://www.dangdang.com/) — China's largest online bookstore.

### Modes

| Mode | Description |
|---|---|
| `search` (default) | Books by free-text keyword (Chinese queries work best) |
| `byProductUrl` | Fetch one product detail page per URL/ID |
| `byCategory` | Browse a book category by code (e.g. `01.03` 小说) |

### Filters

`minPrice` / `maxPrice` (CNY), `minRating` (0–5), `minCommentCount`, `hasDiscount`, `containsKeyword` (title substring), `sortType` (5 orderings: 综合 / 出版时间 / 销量 / 评价数 / 价格升序 — the only params dangdang's search honors), `maxItems`.

### Output fields

`productId`, `title`, `author`, `publisher`, `publishDate`, `isbn`, `priceNow`, `priceOriginal`, `discount` (fold), `rating`, `commentCount`, `coverUrl`, `url`, `sourceUrl`, `scrapedAt`, `recordType`. Typed `error` records for invalid URLs / fetch failures / geo-blocked pages.

### Data Source

Dangdang serves SSR HTML — no login, no API key. Search (`search.dangdang.com`) and category landing pages (`book.dangdang.com/01.xx.htm`) are freely accessible. Product detail pages and the full category listing surface (`category.dangdang.com`) are **sometimes geo-restricted for non-CN IPs** (verified intermittently from non-mainland egress): the actor attempts them directly, then via the Apify AUTO proxy; if still geo-blocked (HTTP 403/405) it emits a typed `GEO_BLOCKED` error record (search/category modes are unaffected).

### Category notes

`byCategory` browses the category landing page (`book.dangdang.com/<code>.htm`) — a curated set of ~50–250 books per category with no pagination. The full paged listing lives on `category.dangdang.com` which can be geo-restricted outside mainland China (see above); the actor de-duplicates across `?page=` fetches and stops when a page yields no new books.

### Anti-bot

Tier 2: `curl_cffi` chrome131 TLS impersonation with rotating browser user-agents, exponential backoff on 403/429/5xx, lazy Apify AUTO-datacenter proxy escalation.

### Limits

- Detail-page geo-restriction is intermittent (see above)
- `rating` is derived from CSS star-fill width where present (search and category landing cards); `commentCount` likewise only when the page carries it (some promoted/featured cards omit both)
- `minRating` / `minCommentCount` are strict: items whose card lacks a parsed `rating` / `commentCount` are excluded when the respective threshold is set (never silently passed through), so the filters always reflect in the output
- Chinese GBK/GB2312 pages decoded via charset sniffing

# Actor input Schema

## `mode` (type: `string`):

What to fetch: search (books by keyword), byProductUrl (single product detail), byCategory (browse a book category).

## `searchQuery` (type: `string`):

Free-text book keyword, e.g. `三体`, `深度学习`. Chinese queries work best.

## `productUrls` (type: `array`):

Dangdang product URLs or IDs, e.g. `https://product.dangdang.com/23579654.html`. Note: detail pages are geo-restricted outside mainland China — those requests fail soft with a typed error record.

## `categoryCode` (type: `string`):

Dangdang book category code, e.g. `01.03` (小说), `01.05` (文学).

## `sortType` (type: `string`):

Result ordering for search mode.

## `minPrice` (type: `number`):

Drop books with a current price below this.

## `maxPrice` (type: `number`):

Drop books with a current price above this.

## `minRating` (type: `number`):

Drop books rated below this (derived from star fill).

## `minCommentCount` (type: `integer`):

Drop books with fewer customer comments than this.

## `hasDiscount` (type: `boolean`):

Only emit books with a discount shown (折扣 < list price).

## `containsKeyword` (type: `string`):

Only emit books whose title contains this text (case-insensitive substring).

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

Hard cap on emitted records.

## Actor input object example

```json
{
  "mode": "search",
  "searchQuery": "三体",
  "productUrls": [],
  "categoryCode": "01.03",
  "sortType": "sort_default",
  "hasDiscount": false,
  "maxItems": 10
}
```

# Actor output Schema

## `books` (type: `string`):

Dataset containing all scraped Dangdang book records.

# 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 = {
    "mode": "search",
    "searchQuery": "三体",
    "productUrls": [],
    "categoryCode": "01.03",
    "sortType": "sort_default",
    "hasDiscount": false,
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/dangdang-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 = {
    "mode": "search",
    "searchQuery": "三体",
    "productUrls": [],
    "categoryCode": "01.03",
    "sortType": "sort_default",
    "hasDiscount": False,
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("crawlerbros/dangdang-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 '{
  "mode": "search",
  "searchQuery": "三体",
  "productUrls": [],
  "categoryCode": "01.03",
  "sortType": "sort_default",
  "hasDiscount": false,
  "maxItems": 10
}' |
apify call crawlerbros/dangdang-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,crawlerbros/dangdang-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/VldGqfXhGB9vPBgc3/builds/xW4Vd6NtjaImAgJ3h/openapi.json
