# Baidu Images Scraper (`searchapi/baidu-images-scraper`) Actor

Search Baidu Images and extract normalized image URLs, source pages, dimensions, formats, and listing metadata with API pagination and DOM fallback.

- **URL**: https://apify.com/searchapi/baidu-images-scraper.md
- **Developed by:** [Search API](https://apify.com/searchapi) (community)
- **Categories:** Developer tools, Automation, Other
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.99 / 1,000 search results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

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

## Baidu Images Scraper

Search Baidu Images by keyword and collect normalized image records. The Actor calls Baidu's structured `data.images` response from the loaded browser session first, validates status and content type before parsing, and supplements incomplete or unavailable API pages with a rendered result-grid fallback.

### Inputs

Use `query` for one phrase or `queries` for a deduplicated batch of up to 25 phrases. Output for `relevance` is interleaved round-robin across queries. `maxItems` is the global cap, `maxItemsPerQuery` is the per-query cap, and `maxPages` is the maximum 30-result API pages per query.

#### Minimal input

```json
{
  "query": "熊猫",
  "maxItems": 10,
  "maxPages": 1,
  "proxyConfiguration": { "useApifyProxy": false }
}
```

#### Batch, pagination, filters, and developer options

```json
{
  "queries": ["猫", "狗"],
  "maxItems": 20,
  "maxItemsPerQuery": 10,
  "maxPages": 2,
  "sortBy": "widthDesc",
  "minWidth": 800,
  "minHeight": 600,
  "fileFormat": "jpg",
  "sourceDomainContains": "example.com",
  "requestDelayMs": 300,
  "maxConcurrency": 2,
  "maxRequestRetries": 1,
  "navigationTimeoutSecs": 60,
  "requestHandlerTimeoutSecs": 120,
  "blockMedia": true,
  "market": "zh-CN",
  "proxyConfiguration": { "useApifyProxy": false }
}
```

#### No-results input

```json
{
  "query": "qzxv9918273645neverexists",
  "maxItems": 5,
  "maxPages": 1,
  "proxyConfiguration": { "useApifyProxy": false }
}
```

`sortBy` supports `relevance`, `titleAsc`, `titleDesc`, `widthDesc`, `heightDesc`, and `sizeDesc`. Width, height, format, and source-domain filters are applied after normalized records are built; missing values do not pass a configured filter.

### Output

The Actor writes one JSON item per unique image URL. The dataset JSON files are available in the run's default dataset storage and through the Apify dataset API/Console links after the run completes. The `OUTPUT` key-value record contains per-query counts, API/DOM fallback usage, page failures, filters, and the final status.

Each record can include:

- stable SHA-256 identity, query/global positions, query/page context, and extraction method;
- image, thumbnail, preview, large/original, host-page, and source URLs;
- source domain/name, title/alt text, dimensions, aspect ratio, pixel count, format, MIME type, and optional file size;
- animation, video, copyright, watermark, AI-edit, commodity, clarity, aurora, and source-type indicators when Baidu publishes them;
- validated API status/content type/attempt metadata, locale, search metadata, and UTC timestamp.

The dataset contract requires at least 20 populated fields per record, including the image and source-page URLs, host domains, query/page positions, and extraction metadata. Optional measurements and labels are omitted when Baidu does not provide them.

No example dataset record is included because Chrome could not load the live Baidu Images search page (`ERR_CONNECTION_TIMED_OUT`) for the required source comparison. No synthetic record is presented as a live extraction. The site and evidence are recorded in the repository's `AGENTS.md`.

### Reliability and access boundaries

The Actor uses bounded retries and exponential backoff for temporary API/browser failures, a shared persistent Playwright context for cookies, optional authorized Apify/custom proxies, and a consistent browser locale. If the host system DNS cannot resolve `image.baidu.com`, it performs a bounded A-record lookup through public DNS and maps only that official hostname inside the browser; if both paths fail, the run reports a failure instead of fabricating records. Media and fonts can be blocked to reduce load; images remain available for DOM fallback and metadata extraction. Verification and CAPTCHA pages fail closed and are never stored as records. The Actor does not solve challenges, bypass authentication, or log cookies, authorization headers, proxy credentials, tokens, or raw API payloads.

### Validation

```text
npm test
npm run check
npm run validate:readme
npm run validate:dataset
npm run validate:run
apify validate-schema
apify run --purge --input-file qa-inputs/one.json
```

The schema validator checks the contract shape. The run validator checks required fields and types, safe URLs, unique IDs, sequential positions, and the `OUTPUT` summary from a completed local run.

# Changelog

This Actor's version history is a separate document: https://apify.com/searchapi/baidu-images-scraper/changelog.md

# Actor input Schema

## `query` (type: `string`):

One phrase to enter in Baidu Images.

## `queries` (type: `array`):

Optional batch of up to 25 phrases. Duplicate phrases are removed and output is interleaved fairly.

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

Hard record limit across all queries.

## `maxItemsPerQuery` (type: `integer`):

Per-query cap before the total limit is applied.

## `maxPages` (type: `integer`):

Maximum number of 30-result structured pages inspected per query.

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

Optional pause between structured API page requests.

## `market` (type: `string`):

Locale used for request language and output metadata.

## `maxConcurrency` (type: `integer`):

Maximum query result pages processed in parallel.

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

Retries temporary navigation, proxy, and browser failures; verification pages are not retried.

## `navigationTimeoutSecs` (type: `integer`):

Maximum page navigation time in seconds.

## `requestHandlerTimeoutSecs` (type: `integer`):

Maximum extraction time for one query in seconds.

## `minWidth` (type: `integer`):

Keep images at or above this source-reported width in pixels.

## `maxWidth` (type: `integer`):

Keep images at or below this source-reported width in pixels.

## `minHeight` (type: `integer`):

Keep images at or above this source-reported height in pixels.

## `maxHeight` (type: `integer`):

Keep images at or below this source-reported height in pixels.

## `fileFormat` (type: `string`):

Optional source image format filter.

## `sourceDomainContains` (type: `string`):

Keep images whose source page domain contains this text.

## `sortBy` (type: `string`):

Sort final normalized records after fair multi-query ordering.

## `blockMedia` (type: `boolean`):

Speeds up runs while preserving HTML, scripts, styles, API calls, and image metadata.

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

Optional Apify Residential or custom proxy configuration. GOOGLE_SERP is not compatible with Baidu.

## Actor input object example

```json
{
  "query": "猫",
  "queries": [],
  "maxItems": 100,
  "maxItemsPerQuery": 100,
  "maxPages": 20,
  "requestDelayMs": 0,
  "market": "zh-CN",
  "maxConcurrency": 2,
  "maxRequestRetries": 1,
  "navigationTimeoutSecs": 60,
  "requestHandlerTimeoutSecs": 120,
  "sortBy": "relevance",
  "blockMedia": true,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `datasetConsole` (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 = {
    "query": "猫",
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("searchapi/baidu-images-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 = {
    "query": "猫",
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("searchapi/baidu-images-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 '{
  "query": "猫",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call searchapi/baidu-images-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,searchapi/baidu-images-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/5bTyg9xHuB9bq95nA/builds/bcVOoS4UPbmJS1mlR/openapi.json
