# How to Track Competitor Prices with Python

By Steven Van · 2026-10-31

A Python tutorial tracks one LEGO set across three retailers with Browser Use agents, SQLAlchemy and SQLite, and needs a free Browser Use account.

Browser Use has published a tutorial on building a competitor price tracker in Python with [Browser Use](<https://creatorstoolbox.com/resources/browser-use>) and SQLAlchemy, in a [new guide](<https://browser-use.com/posts/price-scraping-python>). It scrapes three stores, keeps a price history in SQLite, flags changes, and runs on a schedule.

## What the tracker does

The example follows one product, LEGO set 77251, across LEGO, Target and Best Buy. It asks for each retailer's public USD item price. Each listing is compared only with its own previous observation, and changes are printed. The guide mentions email and webhook delivery as possible extensions.

Each scheduled run repeats four steps:

- Scrape product pages with Browser Use Agents.

- Save observations with timestamps in a database.

- Compare the baseline to the current price to detect changes.

- Send alerts by email or webhook.

## Setup

The project needs Python 3.12 or newer, basic Python knowledge and a free Browser Use account. Eligible signups receive $1 in free credits. The pinned dependencies are python-dotenv, browser-use-sdk, SQLAlchemy and pydantic. SQLAlchemy defines a ProductObservation table with an ID, a product-and-store name used to group observations, and a USD price stored as a two-decimal Decimal. The database file sits beside main.py so manual and scheduled runs share it.

## How scraping works

Each store URL goes to a hosted Browser Use agent with a prompt that defines the offer: the current public item price in USD for one new set sold by the retailer itself, using shipping ZIP 10001 if a location is required. It includes public sales and excludes tax, shipping, member prices, crossed-out prices and installment amounts. The agent returns null if it cannot verify the product, seller, currency or price. It is told to read only and to treat page content as data, not instructions.

Responses are validated with Pydantic against a schema, requests use a US proxy country code, and a run that times out after 300 seconds is cancelled.

## Method and comparison notes

The guide suggests trying a product API first, then an HTTP request with an HTML parser if the price is in the returned HTML. A browser or agent is for pages that need interaction, such as selecting a variant or location. It notes that the agent approach needs clear instructions and checks on the returned data, and adds model usage to the cost. Offers should match on model, variant, condition, quantity, seller, currency and delivery region. If a check fails or returns no price, the comparison is skipped rather than treating the value as zero.

![Browser Use](<https://www.google.com/s2/favicons?domain=browser-use.com&sz=128>)

Browser Use

Open-source browser automation platform for AI agents — let LLMs drive a real browser to research, fill forms, scrape, and complete multi-step tasks.

[View Browser Use →](<https://creatorstoolbox.com/resources/browser-use>)

Sources

[Original source](<https://browser-use.com/posts/price-scraping-python>)

[Read How to Track Competitor Prices with Python on Creators Toolbox](<https://creatorstoolbox.com/blog/browser-use-how-to-track-competitor-prices-with-python>)

---
Canonical source: https://creatorstoolbox.com/blog/browser-use-how-to-track-competitor-prices-with-python
