```yaml
product: AlterLab
title: "How to Scrape E-commerce Prices for Price Monitoring | AlterLab | AlterLab"
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
source_url: https://alterlab.io/how-to/scrape-ecommerce-prices
```

Intermediate5 steps

# How to Scrape E-commerce Prices

Price monitoring requires fetching the same product URLs repeatedly and extracting current prices reliably. E-commerce sites frequently update their page structure, and prices are often loaded dynamically — making standard HTTP scrapers unreliable.

## Step-by-Step Guide

1

### Build your product URL list

Compile the list of product URLs you want to monitor. Include the product ID in your storage so you can match prices across time.

2

### Fetch each page with browser rendering

Send each URL to the AlterLab API with render_js enabled to ensure dynamically loaded prices are captured.

3

### Extract the price with a CSS selector

Inspect the target product page to find the CSS selector for the price element. Use BeautifulSoup or lxml to extract it from the rendered HTML.

4

### Store prices with timestamps

Write price records to a database or CSV file with timestamps. Compare new records to previous ones to detect price changes.

5

### Schedule recurring jobs

Run your price-extraction script on a schedule (hourly, daily) using cron, Celery, or a cloud scheduler.

## Code Example

Python

```
import requests
from bs4 import BeautifulSoup

def get_price(product_url: str, api_key: str, price_selector: str) -> str | None:
    response = requests.post(
        "https://alterlab.io/api/v1/scrape",
        headers={"X-API-Key": api_key, "Content-Type": "application/json"},
        json={"url": product_url, "render_js": "auto"},
    )
    html = response.json().get("html", "")
    soup = BeautifulSoup(html, "html.parser")
    el = soup.select_one(price_selector)
    return el.get_text(strip=True) if el else None

price = get_price(
    "https://www.example-store.com/product/123",
    "YOUR_API_KEY",
    ".product-price",
)
print(f"Current price: {price}")
```

Replace `YOUR_API_KEY` with your key from the . No credit card required.

## Try this yourself with AlterLab

Run this tutorial on live websites with AlterLab's API. New accounts get up to 5,000 free requests — no credit card required.

[View API docs](https://alterlab.io/docs/api/rest)

## Frequently Asked Questions

### How do I handle price formats that vary by region?

Extract the raw text from the price element and apply locale-aware parsing (e.g., Python's `babel` library) to normalize currencies and decimal formats.

### What if a CSS selector stops working when the site redesigns?

Store multiple selector fallbacks and test them in order. Consider using AlterLab's structured extraction feature to extract prices by semantic context rather than exact CSS class names.

### Responsible Use

AlterLab is designed for extracting publicly available data. Always review the terms of service for any website you access, respect `robots.txt` directives, and ensure your use case complies with applicable laws in your jurisdiction.

### More tutorials

Browse all [how-to guides](https://alterlab.io/how-to) for web scraping — from beginner extractions to advanced multi-page pipelines.

## Your first scrape. Sixty seconds.

Up to 5,000 free requests — about 5,000 Light, 500 Protected or 250 Dynamic requests. No credit card. 
Just a POST request.

terminal

curl -X POST https://api.alterlab.io/v1/scrape \

-H "X-API-Key: YOUR_KEY" \

-H "Content-Type: application/json" \

-d '{"url": "https://example.com", "formats": ["markdown"]}'

[Start building free](https://alterlab.io/signin)

No credit card required · Up to 5,000 free requests (about 5,000 Light, 500 Protected or 250 Dynamic requests) · Balance never expires