```yaml
product: AlterLab
title: "How to Scrape H&M Data: Complete Guide for 2026"
category: Tutorials
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
last_updated: 2026-07-21
canonical_facts:
  - "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."
source_url: https://alterlab.io/blog/how-to-scrape-h-m-data-complete-guide-for-2026
```

# How to Scrape H&M Data: Complete Guide for 2026

This 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](/docs/quickstart/installation).

```python title="scrape_hm-com.py" {3-5}
import alterlab

client = alterlab.Client("YOUR_API_KEY")
response = client.scrape("https://www2.hm.com/en_us/productpage.1234567890.html")
print(response.text[:500])
```

```javascript title="scrape_hm-com.js" {3-5}
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));
```

```bash title="Terminal"
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
```python title="parse_hm-com.py"
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
```javascript title="parse_hm-com.js"
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.

```python title="extract_hm-com_structured.py"
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 output
```

Cortex 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](/pricing) page for volume discounts and enterprise options.

<div data-infographic="stats">
  <div data-stat data-value="99.2%" data-label="Success Rate"></div>
  <div data-stat data-value="1.2s" data-label="Avg Response"></div>
  <div data-stat data-value="$0

## Frequently Asked Questions

### Is it legal to scrape h&m?

Scraping publicly accessible data is generally permissible under rulings like hiQ v LinkedIn, but you must review H&M’s robots.txt and Terms of Service, apply rate limiting, and avoid private or login‑gated information.

### What are the technical challenges of scraping h&m?

H&M employs standard anti‑bot measures such as request rate limits, header checks, and occasional JavaScript challenges. AlterLab’s Smart Rendering API automatically handles proxy rotation, header generation, and browser rendering when needed.

### How much does it cost to scrape h&m at scale?

Costs start at $0.0002 per request for static HTML (T1) and rise to $0.004 per request for full JavaScript rendering (T4). AlterLab auto‑escalates tiers, so you only pay for the level that succeeds.

## Related

- [How to Migrate from Diffbot to AlterLab: Step-by-Step Guide \(2026\)](<https://alterlab.io/blog/how-to-migrate-from-diffbot-to-alterlab-step-by-step-guide-2026>)
- [Building a Real-Time News Aggregator with Web Scraping](<https://alterlab.io/blog/building-a-real-time-news-aggregator-with-web-scraping>)
- [The Verge Data API: Extract Structured JSON in 2026](<https://alterlab.io/blog/the-verge-data-api-extract-structured-json-in-2026>)