How to Scrape DHgate in Node.js
A minimal Node.js example showing how to scrape DHgate product listings using the DHgate Listings Scraper actor on Apify. Instead of building a scraper from scratch with Playwright or Cheerio, this example calls a ready-made Apify actor that handles the heavy lifting — search URL parsing, pagination, and structured data extraction.

What this example does
- Calls the
piotrv1001/dhgate-listings-scraper Apify actor
- Passes a DHgate search URL as input
- Waits for the actor run to finish
- Fetches results from the run’s dataset
- Prints each product listing to the console
Prerequisites
Installation
npm install
Environment setup
Copy .env.example to .env and add your Apify API token:
cp .env.example .env
APIFY_TOKEN=your_apify_token_here
Usage
npm start
Code example
import { ApifyClient } from 'apify-client';
import 'dotenv/config';
const client = new ApifyClient({
token: process.env.APIFY_TOKEN,
});
const input = {
"searchUrls": [
"https://www.dhgate.com/w/sneakers.html?dspm=pcen.hp.hotsearch.5.PyrNzJX8tC4mkXEVKusV&resource_id=#listing_hot-sneakers"
]
};
const run = await client.actor("piotrv1001/dhgate-listings-scraper").call(input);
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);
});
Example output
See sample-output.json for a full example of what the actor returns. Each product listing includes:
itemCode and productId — DHgate identifiers
productName and alt — product title and image alt text
productDetailUrl — direct link to the product page
imageUrl — product thumbnail
price and minOrder — pricing and minimum order quantity
feedbackPercent, reviewCount, recentlySold — seller and product stats
sellerStoreUrl — link to the seller’s store
freeShipping — boolean shipping flag
coupons — array of available coupon codes
Use cases
- Price monitoring — track DHgate prices for specific product categories over time
- Product research — find trending sneakers, electronics, or apparel for resale
- Competitive analysis — benchmark seller pricing and reviews
- Dropshipping product discovery — surface high-rated, free-shipping products
- Market data pipelines — feed structured DHgate listings into analytics dashboards
Try the actor on Apify
Open the DHgate Listings Scraper on Apify
License
MIT
评论