# DHGate Products Scraper (`codingfrontend/dhgate-products-scraper`) Actor

Find profitable, low-MOQ products from DHGate.com, identify winning products for dropshipping and e-commerce resale.

- **URL**: https://apify.com/codingfrontend/dhgate-products-scraper.md
- **Developed by:** [Coding Frontned](https://apify.com/codingfrontend) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.99 / 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.

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

## DHgate Products Scraper

This Actor extracts source-backed product data from public DHgate product and category pages. It can emit product identity, structured offer prices and tiers, MOQ, specifications, images, shipping summaries, seller-store references, and aggregate review fields when DHgate exposes them publicly.

The Actor uses direct public HTTPS requests to DHgate only. It does not log in, use private APIs, rotate proxies, solve CAPTCHAs, or bypass access controls. Robots.txt is checked before a live page request, redirects stay within the DHgate boundary, and challenge or blocked responses are emitted as diagnostics rather than being treated as products.

### Input

Provide one or more public DHgate product or category URLs in `startUrls`. When the field is omitted, the default public DHgate homepage is checked. Invalid explicit URLs are reported and never replaced with a default URL. `maxItems` bounds product records, `timeoutSecs` bounds each request, `maxRetries` bounds retryable failures, `requestDelayMs` spaces retries, and `maxBytes` limits one response.

For deterministic local validation, set `sourceMode` to `fixture` and provide `fixtureHtml` or a local `fixtureFile` inside the Actor directory. Fixture mode never falls back to the network.

Example:

```json
{
  "startUrls": ["https://www.dhgate.com/product/example-wireless-earbuds/123456789.html"],
  "maxItems": 10,
  "timeoutSecs": 30,
  "maxRetries": 2
}
```

### Output

Normal records contain only documented public source and business fields: source URLs, product identity, pricing, public supplier/store signals, images, specifications, reviews, and `scrapedAt`. They intentionally omit transport, request, extraction, quality, and other operational instrumentation. Diagnostics are separate minimal rows with exactly `recordType: "diagnostic"`, `url`, `errorCode`, `error`, and `scrapedAt`.

You can download the dataset in various formats such as JSON, HTML, CSV, or Excel.

The default key-value store contains `OUTPUT`, `OUTPUT_SUMMARY`, `RUN_SUMMARY`, and `SUMMARY` aliases plus `SOURCE_METADATA` and `DIAGNOSTICS`.

### Limits and responsible use

Only public product and aggregate seller signals are emitted. Contact details, account data, credentials, cookies, private supplier fields, and challenge state are excluded. DHgate may return Cloudflare or other access-control pages depending on region and request conditions; the truthful local result in that case is a blocked diagnostic and not a publishable product dataset.

For local development, run `npm run check` and validate an isolated Actor run with `npm run validate` plus `ACTOR_DATASET_DIR` pointing to that run's dataset directory. Cloud builds, remote runs, deployment, and publication are separate release gates.

# Actor input Schema

## `startUrls` (type: `array`):

One or more public HTTP(S) URLs. URL access controls are reported rather than bypassed.

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

Maximum number of distinct product records to store.

## `timeoutSecs` (type: `integer`):

Per-URL public request timeout.

## `maxRetries` (type: `integer`):

Attempts for retryable public request failures.

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

Delay between retryable public requests.

## `maxBytes` (type: `integer`):

Safety limit for one public response.

## `includeDiagnostics` (type: `boolean`):

Emit access and no-data diagnostics to the dataset.

## `sourceMode` (type: `string`):

Use live for public DHgate requests or fixture for deterministic local validation. Fixture mode never falls back to live.

## `fixtureHtml` (type: `string`):

Optional local HTML fixture for deterministic validation.

## `fixtureFile` (type: `string`):

Local HTML fixture path inside the Actor directory.

## `fixtureFiles` (type: `array`):

One local HTML fixture per target, or one fixture reused for all targets.

## Actor input object example

```json
{
  "startUrls": [
    "https://www.dhgate.com"
  ],
  "maxItems": 10,
  "timeoutSecs": 30,
  "maxRetries": 2,
  "requestDelayMs": 300,
  "maxBytes": 5000000,
  "includeDiagnostics": true,
  "sourceMode": "live",
  "fixtureHtml": ""
}
```

# Actor output Schema

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

Dataset containing public-source records.

## `keyValueStore` (type: `string`):

Key-value store containing the OUTPUT run summary.

# 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 = {
    "startUrls": [
        "https://www.dhgate.com"
    ],
    "maxItems": 10,
    "timeoutSecs": 30,
    "maxRetries": 2,
    "requestDelayMs": 300,
    "maxBytes": 5000000
};

// Run the Actor and wait for it to finish
const run = await client.actor("codingfrontend/dhgate-products-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 = {
    "startUrls": ["https://www.dhgate.com"],
    "maxItems": 10,
    "timeoutSecs": 30,
    "maxRetries": 2,
    "requestDelayMs": 300,
    "maxBytes": 5000000,
}

# Run the Actor and wait for it to finish
run = client.actor("codingfrontend/dhgate-products-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 '{
  "startUrls": [
    "https://www.dhgate.com"
  ],
  "maxItems": 10,
  "timeoutSecs": 30,
  "maxRetries": 2,
  "requestDelayMs": 300,
  "maxBytes": 5000000
}' |
apify call codingfrontend/dhgate-products-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,codingfrontend/dhgate-products-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/VxHzaxWKqO9LP3QMe/builds/Sbkbh0eXCEeYxnmsN/openapi.json
