```yaml
product: AlterLab
title: "How to Build a Price Comparison Tool with Web Scraping | AlterLab | AlterLab"
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
source_url: https://alterlab.io/how-to/build-price-comparison-tool
```

Advanced5 steps

# How to Build a Price Comparison Tool

Comparing prices across multiple retailers requires fetching product pages from different sites simultaneously, normalizing diverse price formats, and matching the same product across different naming conventions — all on a recurring schedule.

## Step-by-Step Guide

1

### Define your product catalog

Create a list of products with their URLs on each retailer you want to monitor. Use a consistent product identifier (SKU, GTIN) to match products across sites.

2

### Build site-specific extractors

Write a selector configuration for each retailer's price element. Store these as a dictionary keyed by domain so you can apply the right extractor per URL.

3

### Fetch prices in parallel

Use AlterLab's batch endpoint to fetch multiple product URLs simultaneously, reducing total collection time.

4

### Normalize and compare

Convert all prices to a common currency and decimal format. Sort by price to find the cheapest option and flag significant price changes.

5

### Schedule and alert

Run comparisons on a schedule. Send alerts when a tracked product drops below a price threshold.

## Code Example

Python

```
import requests
from bs4 import BeautifulSoup

RETAILER_SELECTORS = {
    "example-store-a.com": ".product-price",
    "example-store-b.com": "#price-display",
}

def get_price(url: str, api_key: str) -> str | None:
    from urllib.parse import urlparse
    domain = urlparse(url).netloc.replace("www.", "")
    selector = RETAILER_SELECTORS.get(domain)
    if not selector:
        return None

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

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 variations (sizes, colors)?

For variable products, you may need to scrape each variant URL separately or intercept the XHR requests that return variant pricing data from the product page JavaScript.

### 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