Skip to content

piotrv1001/how-to-scrape-jd-com-in-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to Scrape JD.com in Node.js

This example shows how to scrape product data from JD.com (京东) in Node.js using the JD.com Product Scraper on Apify. Instead of building a scraper from scratch — dealing with anti-bot protection, proxies, and parsing — you call a ready-made Apify actor through the official apify-client package and get structured JSON back.

JD.com Product Scraper results

What this example does

  • Calls the piotrv1001/jd-com-product-scraper actor via the Apify API
  • Passes an input with JD.com SKU IDs (or product page URLs) to scrape
  • Waits for the actor run to finish
  • Fetches the scraped results from the run's dataset
  • Prints each product item to the console

Prerequisites

Installation

npm install

Environment setup

Copy the example env file and add your Apify API token:

cp .env.example .env
APIFY_TOKEN=your_apify_token_here

Usage

npm start

The script runs the actor, waits for it to finish, and prints the scraped JD.com products. You'll also get a link to view the dataset in the Apify Console.

Code example

import { ApifyClient } from 'apify-client';
import 'dotenv/config';

// Initialize the ApifyClient with your Apify API token
// Set APIFY_TOKEN in your .env file (copy .env.example to get started)
const client = new ApifyClient({
    token: process.env.APIFY_TOKEN,
});

// Prepare Actor input
const input = {
    "skuIds": [
        "100008348542"
    ],
    "startUrls": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("piotrv1001/jd-com-product-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

Example output

See sample-output.json for a full example. Each scraped product includes:

Field Description
skuId JD.com SKU identifier
url Product page URL
title / name Full product title and name
brandId / brandName Brand info (e.g. Apple, 富士)
shopId / shopName Seller / store info
categoryIds / categoryNames Category hierarchy
breadcrumb Full breadcrumb path
mainImage / images Product image URLs
description Product description
scrapedAt Timestamp of the scrape

Use cases

  • Price & catalog monitoring — track JD.com product listings for e-commerce intelligence
  • Competitor research — analyze brands, sellers, and category positioning on China's largest B2C marketplace
  • Product data enrichment — pull titles, images, and category data into your own catalog or PIM
  • Market analysis — study product assortment and branding trends across JD.com categories
  • Dropshipping & sourcing — collect structured product data for sourcing decisions

Try the actor on Apify

Open the JD.com Product Scraper on Apify

Related resources

License

MIT

About

How to scrape JD.com product data in Node.js using the JD.com Product Scraper on Apify — SKU details, brand, shop, categories, and images as structured JSON.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors