
How to Scrape H&M Data: Complete Guide for 2026
Learn to scrape H&M product data with Python and Node.js using AlterLab’s API. Covers anti-bot handling, structured extraction, pricing, and responsible scraping practices.
AlterLab handles this automatically — scrape any URL with one API call. No infrastructure required.
Try it freeThis guide covers extracting publicly accessible data. Always review a site's robots.txt and Terms of Service before scraping.
TL;DR
To scrape H&M product pages, send a request to AlterLab’s API with the target URL, parse the returned HTML with CSS selectors, and optionally use Cortex for typed JSON output. Start at tier T1 and let the API promote automatically if anti‑bot measures require more advanced handling.
Why collect e-commerce data from H&M?
- Price monitoring: Track changes in product pricing across categories to inform competitive pricing strategies.
- Market research: Analyze product availability, description updates, and new arrivals to spot trends.
- Data analysis: Build datasets for machine learning models that predict fashion demand or style popularity.
Technical challenges
H&M’s public pages include typical e‑commerce protections: rate limiting per IP, header validation (User‑Agent, Accept), and occasional JavaScript‑based checks that block simple HTTP clients. Raw requests often receive HTTP 429 or challenge pages. AlterLab’s Smart Rendering API manages proxy rotation, header generation, and headless browser fallback, letting you focus on data extraction rather than bypass mechanics.
Quick start with AlterLab API
First, install the SDK and make a basic scrape request. The examples below show Python, Node.js, and cURL. For setup details, see the Getting started guide.
import alterlab
client = alterlab.Client("YOUR_API_KEY")
response = client.scrape("https://www2.hm.com/en_us/productpage.1234567890.html")
print(response.text[:500])import { AlterLab } from "alterlab";
const client = new AlterLab({ apiKey: "YOUR_API_KEY" });
const response = await client.scrape("https://www2.hm.com/en_us/productpage.1234567890.html");
console.log(response.text.slice(0, 500));curl -X POST https://api.alterlab.io/v1/scrape \
-H "X-API-Key: YOUR_KEY" \
-d '{"url": "https://www2.hm.com/en_us/productpage.1234567890.html"}'The response contains the raw HTML of the product page. You can now parse it with libraries like BeautifulSoup (Python) or cheerio (Node.js).
Extracting structured data
Once you have the HTML, target visible elements with CSS selectors. On an H&M product page, common data points include:
- Product title:
h1.product-item-headline - Price:
span.price-value - Rating:
div.rating-stars(data‑rating attribute) - Description:
div.pdp-description-inner
Python example with BeautifulSoup
from bs4 import BeautifulSoup
import alterlab
client = alterlab.Client("YOUR_API_KEY")
html = client.scrape("https://www2.hm.com/en_us/productpage.1234567890.html").text
soup = BeautifulSoup(html, "html.parser")
title = soup.select_one("h1.product-item-headline").get_text(strip=True)
price = soup.select_one("span.price-value").get_text(strip=True)
rating_elem = soup.select_one("div.rating-stars")
rating = rating_elem["data-rating"] if rating_elem else None
description = soup.select_one("div.pdp-description-inner").get_text(strip=True)
print({"title": title, "price": price, "rating": rating, "description": description})Node.js example with cheerio
import { AlterLab } from "alterlab";
import cheerio from "cheerio";
const client = new AlterLab({ apiKey: "YOUR_API_KEY" });
const html = await client.scrape("https://www2.hm.com/en_us/productpage.1234567890.html");
const $ = cheerio.load(html);
const title = $("h1.product-item-headline").text().trim();
const price = $("span.price-value").text().trim();
const rating = $("div.rating-stars").attr("data-rating");
const description = $(".pdp-description-inner").text().trim();
console.log({ title, price, rating, description });Structured JSON extraction with Cortex
For a more direct approach, use AlterLab’s Cortex extraction API to receive typed JSON without writing selectors. Define a JSON Schema that matches the fields you need.
import alterlab
client = alterlab.Client("YOUR_API_KEY")
result = client.extract(
url="https://www2.hm.com/en_us/productpage.1234567890.html",
schema={
"type": "object",
"properties": {
"title": {"type": "string"},
"price": {"type": "number"},
"rating": {"type": "number"},
"description": {"type": "string"}
},
"required": ["title", "price"]
}
)
print(result.data) # Typed JSON outputCortex returns validated JSON, reducing post‑processing work and handling page variations automatically.
Cost breakdown
AlterLab’s pricing is usage‑based. The table below shows the cost per request and per 1,000 requests for each tier. For H&M, start at T1; the API will promote to T2‑T4 if anti‑bot measures require more advanced handling, and you only pay for the tier that succeeds.
| Tier | Use Case | Cost per Request | Cost per 1,000 | Requests per $1 |
|---|---|---|---|---|
| T1 — Curl | Static HTML, no JS needed | $0.0002 | $0.20 | 5,000 |
| T2 — HTTP | Standard pages with headers | $0.0003 | $0.30 | 3,333 |
| T3 — Stealth | Protected pages, anti-bot active | $0.002 | $2.00 | 500 |
| T4 — Browser | Full JS rendering required | $0.004 | $4.00 | 250 |
| T5 — CAPTCHA | CAPTCHA solving + JS rendering | $0.02 | $20.00 | 50 |
See the full AlterLab pricing page for volume discounts and enterprise options.
Was this article helpful?
Frequently Asked Questions
Related Articles

Structured Extraction vs. Raw Scraping for LLM Apps
Learn the differences between raw HTML scraping and structured AI extraction. Discover how to optimize data pipelines for LLM and RAG applications.
Herald Blog Service

Weekly Product Roundup: SDK Drift Fix, CI Unblocking, Session Security & WAF Improvements
This week's AlterLab engineering updates resolve SDK response drift, unblock CI migrations, enhance session binding security, and reduce WAF false positives for more reliable scraping pipelines.
Herald Blog Service

Understanding MCP Servers: Connecting AI to the Real-Time Web
Learn how Model Context Protocol (MCP) servers enable AI agents to access real-time web data via standardized, secure, and scalable API connections.
Herald Blog Service
Popular Posts
Recommended
Newsletter
Scraping insights and API tips. No spam.
Recommended Reading

How to Scrape AliExpress: Complete Guide for 2026

Why Your Headless Browser Gets Detected (and How to Fix It)

AlterLab vs Firecrawl: Which Scraping API Is Better in 2026?

How to Scrape Twitter/X Data: Complete Guide for 2026

How to Scrape Cloudflare-Protected Sites in 2026
Stay in the Loop
Get scraping insights, API tips, and platform updates. No spam — we only send when we have something worth reading.
Explore AlterLab
Anti-Bot Handling API
Automatic challenge handling for protected sites — works out of the box.
JavaScript Rendering API
Render SPAs and dynamic content with headless Chromium.
Pricing
5-tier pricing from $0.0002/page. 5,000 free requests to start.
Documentation
API reference, SDKs, quickstart guides, and tutorials.
Web Scraping API Resources
Part of the Web Scraping API Documentation cluster
Complete API reference with 5-tier auto-escalation — Curl to challenge resolution.
Pillar pageConfigure Tier 4 browser rendering for SPAs and dynamic content.
Scrape pages behind login using session management.
Real success rates and cost data across all 5 tiers.
MCP Server, Python SDK, and Firecrawl-compatible API for AI agent workflows.