How to Build a Competitor Price Tracker with Python
TL;DR
Build a watchlist from exact models, variants, sellers, and markets. Keep product discovery separate from the recurring task that collects approved product URLs.
Use Nstdata Crawl, a Web Crawling API for LLM-ready data, to retrieve page evidence through MCP. Its Local adapter supplies the collection tools used by the runnable Python example.
The included collector validates an offer, stores each attempt in SQLite, and exports observed prices and changes. It reserves one slot per listing, transport, and UTC window before submission.
Run one approved listing first. Confirm the one-time amount, currency, and stock evidence before running a larger watchlist.
A failed capture leaves a coverage gap. Preserve the last verified price and its original time. Compare deltas only within the same verified listing and currency.
The recorded Sony headphones pilot includes six accepted prices across three listings and three unchanged comparisons. Replay the CSV offline before attaching a scheduler.
A daily overwrite can tell you today's price and erase the evidence you need tomorrow. A competitor price tracker should answer three questions: which offer did we observe, when did we observe it, and what changed since the last comparable observation? This guide builds that record with Python and SQLite. The example starts with reviewed storefront URLs and uses the official Nstdata Crawl MCP adapter as its collection layer.
What Does a Competitor Price Tracker Need to Record?
A competitor price tracker records timestamped offers for exact product listings and keeps enough evidence to compare them later. Model, variant, condition, seller, market, and offer basis determine whether two rows are comparable.
Store one verified baseline before detecting changes. When a later capture gives a different amount, report when it was first observed. If two observations are hours apart, the exact time the page changed remains unknown.
How Do You Turn a Product Name into a Reviewed Watchlist?
Use a search service or catalog to locate candidates, then verify each storefront page before adding it to the scheduled watchlist. Product names often match accessories, similarly named models, and different conditions.
Start with Sony WH-1000XM5 Black. Search by manufacturer model and market, optionally restricting the query to eligible retailers. Open the candidate page and confirm the model, finish, condition, seller, and packaging. Be careful with URL parameters that carry variant or locale selections. Once reviewed, fix each listing ID to one offer basis. If the retailer replaces the product or changes the selected configuration, update the mapping after review.
The reviewed watchlist contains three public product URLs and their page-specific patterns. Save it as watchlist.json and run this local catalog lookup in that folder to reproduce the mapping from an exact model and variant. The input represents an existing, curated collection of listings.
import json
from pathlib import Path
rows = json.loads(Path("watchlist.json").read_text(encoding="utf-8"))for row in rows:if row["model"]=="WH-1000XM5"and row["variant"]=="Black":if row["market"]in{"US","UK"}:print(f"{row['id']} | {row['market']} | {row['currency']}")
sony-us-black-standard | US | USD
john-lewis-uk-black-standard | UK | GBP
bh-us-black-standard | US | USD
For a permitted category page with an unknown set of product URLs, Crawl can follow links from that approved seed. Use nstdata_crawl_start with a page and depth cap, then read nstdata_crawl_status and nstdata_crawl_pageswith the same crawlId. Inspect each page's outcome and pass the returned nextCursor as afterCursor when paging ahead. Keep site discovery on a separate cadence from price checks. The verified Sony example uses a reviewed watchlist and single-page collection.
What Does Nstdata Crawl Handle for the Python Tracker?
Nstdata Crawl is a Web Crawling API for LLM-ready data. It handles page retrieval, optional rendering, bounded traversal, and result delivery. Python controls which sources to collect, what evidence makes a valid offer, and when to send an alert. Official Nstdata MCP repository
Inspect dynamic offers. Use options.jsRender.waitForSelector when the storefront has a verified signal that the selected variant's price is present. A fixed waitFor helps reproduce an initial sample. Use targetSelectorafter confirming it keeps related promotion and purchase-control text.
Select the evidence you need. Crawl MCP supports markdown, html, links, pdf, screenshot, and rawData. Use Markdown for this collector's text rules, HTML for markup analysis, links for site discovery, PDF or screenshot for visual review, and raw data for diagnostics. The normalized SQL row and CSV are generated by the Python application.
Manage routes in Crawl. Send a two-letter code through options.proxy.country when you need to request country routing. No separate proxy URL or credentials go in the job. Verify the served storefront and currency, and confirm the exit location separately if the report requires it. Crawl Proxy traffic can be billed separately.
Resume by ID or read reference content. An asynchronous single-page result is queried with nstdata_crawl_scrape_result by passing the id from the submission response as taskId. Site jobs use a crawlId. Stored artifacts use their own result references. Keep these identifiers distinct in the database.
Crawl can supply evidence even when a task ultimately fails business validation. An accepted offer still needs the correct amount, currency, model, and purchase conditions.
Collect Product Page Evidence with Nstdata Crawl
Start with one verified product page and retrieve the content your Python tracker needs.
Use Local MCP for the Python worker and Hosted MCP when an assistant with Streamable HTTP needs to review a page. Both connect to the managed Crawl service.
Step 1 — Prepare the local runtime
Use Python 3.9+ and Node.js 22.18+ within the Node 22 series or Node 24. Make npx available on the client's path. The pilot used Python 3.9.6, Node.js 22.23.2, and the official server 1.0.5. Get a Crawl API key and confirm available account credits. Set NSTDATA_API_TOKEN in the worker's environment through a trusted secret source.
The Python worker starts the official adapter itself. To inspect the tool calls in Codex first, merge this example into your protected user-level ~/.codex/config.toml. Use the same fields if adding a stdio server in the app. Restart the connection and verify the six Crawl tools.
Step 2 — Connect a hosted assistant when you need one
Add https://mcp.nstdata.io/crawl as a Streamable HTTP connection. The Codex desktop MCP settings or Plugins → Add → Add MCP server can register that endpoint. In the client's authorization flow, enter your Crawl API key on the Nstdata authorization page. Keep manual bearer-token fields and custom headers empty for OAuth. Alternatively, an HTTP client with static headers can send the key through X-API-Key. Enable one Crawl connection for the assistant session.
In Codex CLI, the second command is needed only if adding the server did not start authorization.
The worker uses nstdata_crawl_scrape with mode: "sync" and formats: ["markdown"]. The request below was used for the John Lewis page. The upstream timeout is 25 seconds and the render wait is three seconds. A client timeout is a separate boundary. When the submission outcome is unclear, inspect task history before submitting it again.
Confirm the task returns completed with success: true. If it supplies data.markdownRef, call nstdata_crawl_read_result with its value as ref, format: "markdown", and starting offset: 0. Follow the reported nextOffset within your read limit. The sample worker caps this at two chunks. It checks the canonical host, model, variant, and offer region before parsing the price.
For higher volume, plan asynchronous retrieval separately. Submit mode: "async", store the returned ID, and query nstdata_crawl_scrape_result with that ID as taskId. The sample worker uses sequential synchronous requests. Hosted setup, asynchronous polling, and site discovery above are documented paths. The recorded price pilot used Local MCP.
How Do You Run the Python Collector and Store Price History?
Run the complete Python collector with the reviewed watchlist. It records an attempt before each request and exports the outcomes and like-for-like changes after the run.
Step 1 — Start with one verified listing
Save the collector and watchlist.json together. In that folder, run the following after injecting NSTDATA_API_TOKENinto the shell. This command uses one approved public product page and one window. A new capture can consume Crawl credits.
Inspect output/results.csv to see whether the result was accepted, needs review, or failed. If you want to capture all three reviewed listings, omit --listing. When you add a new retailer, supply and test its own price pattern. A generic amount matcher would also find financing, used goods, shipping, and cross-sell prices.
Step 2 — Keep one reservation per collection window
The demo stores all attempts in one SQLite table. Its primary key is (window, listing_id, transport). The worker reserves that key before requesting a page and skips an already reserved record. A record left in running after interruption needs investigation. Review its outcome before creating a new collection window. Scheduled slot and actual UTC observation time serve different purposes.
For larger deployment, separate listing definitions, attempts, observations, and alert events. Store known asynchronous task IDs so an interrupted poller can resume. Keep emitted alerts keyed by the two snapshot IDs and event type. SQLite is useful for a small single-worker watchlist, and a queue or managed database may suit multiple collectors. SQLite constraints
Step 3 — Export results from your collected database
Once a capture exists in black-friday.sqlite3, repeat the export as needed. This command uses the existing database and does not make a collection request.
The change export uses the previous accepted price for the same listing, transport, and currency. If the latest attempt failed, the latest accepted price remains available with its original timestamp. Check results.csv alongside changes.csv before reporting that a product's price held steady.
How Do You Detect Changes and Schedule Repeat Checks?
Compare each accepted observation with the prior comparable snapshot. Schedule another capture with a new UTC window only when the desired observation time arrives.
The change definition is current price minus previous price. For percentages, divide the signed change by the previous amount when positive, then multiply by 100. Keep availability, membership, coupon, and reference-price changes as separate event types. A first accepted row establishes the baseline. Unknown stock or a missed capture stays unknown until new evidence arrives.
Download the historical changes CSV to the working folder. This offline snippet combines exact minor-unit amounts with a threshold to print an alert decision. The example threshold is 100 cents or pence, depending on each row's currency.
import csv
from decimal import Decimal
from pathlib import Path
threshold_minor =100with Path("changes.csv").open(encoding="utf-8", newline="")as stream:for row in csv.DictReader(stream): prior =int(row["previous_price_minor"])if prior <=0:continue change =int(row["price_minor"])- prior
percent = Decimal(change)*100/ prior
status ="alert"ifabs(change)>= threshold_minor else"review_only"print(f"{row['listing_id']} | {row['currency']} | {percent:+.2f}% | {status}")
Schedule your shell wrapper through a job runner or Cron that starts in the demo folder, durably mounts the database directory, and receives the API key through the runner's secret configuration. Use a lock or a single-worker job policy to prevent overlap. Pass a shared UTC bucket when a scheduler retries the same intended observation. The minute-based command above is a useful interactive smoke test. If the scheduler retries several minutes later, pass the original bucket explicitly. Add cap limits by retailer and record the age of the last accepted price.
What Did the Sony Headphone Pilot Actually Show?
The November 23, 2026 Local MCP pilot produced six accepted observations across three Sony WH-1000XM5 Black product listings. The same-listing price was unchanged in each short recheck.
The first accepted John Lewis observation becomes the following application record. The amount is in pence and the missing reference price remains null.
{"listing_id":"john-lewis-uk-black-standard","market":"UK","currency":"GBP","price_minor":19900,"reference_minor":null,"purchase_control":"currently in stock online","observed_at":"2026-11-23T07:11:37+00:00"}
Amounts are historical page displays before any separately assessed delivery or checkout conditions. No comparable reference price was verified. The market labels describe the storefronts and the pilot did not check network exits. Five extra probes on other pages were excluded because the capture failed or did not establish the desired price. The six accepted captures and verification record provide timestamps, sources, and the attempted scope. Use the pilot as a working baseline for your integration. Assess longer-term pricing trends after collecting the necessary history.
How Do You Diagnose Missing or Duplicate Price Alerts?
Start with the latest attempt state and determine whether the gap arose during submission, collection, offer validation, or delivery.
Start with the single-listing run and verify the amount and purchase signal. If the permitted flow requires interactive browser state, inspect it with Nstdata Cloud Browser.
Run a small supervised capture and verify its evidence before relying on scheduled alerts.
Q: Can I use the same product ID across several countries?
You can group equivalent products under one product ID. Use distinct listing IDs and retain local currency and storefront context so the price detector compares only like-for-like offers.
Q: Is SQLite enough for a first tracker?
Yes, for a small watchlist with a controlled write path and a clear backup plan. Revisit storage when concurrent writes, retention, or alert history require a separate service.
Q: What happens if a URL starts showing a different product?
Hold the observation for review. Keep the previous price and its timestamp. Approve a new URL mapping before resuming comparable snapshots.
Q: Does the Crawl tool schedule checks or send alerts?
The tool retrieves evidence when called. Your job runner schedules checks and your Python application stores prices, compares them, and prepares alert events.
Build a Python and SQLite tracker that compares verified retail offers over time. Start with a reviewed watchlist, collect page evidence through Nstdata Crawl MCP, and use the stored observations to detect price changes.
Marcus Chen
Nov. 24th 2026
110M+ real IPs with 99.9% access success
Blazing-fast average response ~0.5s for high-concurrency tasks
From only $0.1/GB
Get immediate access to premium residential, datacenter, IPv6 and ISP proxy pools.