Build a price monitoring scraper: product fields, daily runs and change detection
Build a price monitoring scraper: a product extractor with typed prices, daily batch or scheduled runs, a signed webhook and change detection in your code.
- Published
- Reading time
- 9 min read
- By
- ExtractHub team
- price monitoring
- web scraping
- batch
- webhooks
- tutorial
On this page
A price monitoring scraper sounds like one request in a loop: fetch the product page, read the price, compare it with yesterday’s. The fetch is the easy part. The hard parts are getting a price you can compare (a number, with its currency), running it on time over every product, and telling a real price change apart from a page that did not load.
This post builds a price monitoring scraper with ExtractHub in four parts: a product extractor that returns typed values, a daily run over your URL list (a batch from your own scheduler, or a scheduled pipeline), a webhook that tells you the run is done, and change detection in your own code. The examples use example.com as an illustrative example; they are not the selectors or data of a real shop.
What a price monitor is made of
Split the job by who owns each part:
| Part | Where it runs |
|---|---|
| Read title, SKU, price, currency, availability from a product page | an extractor (a versioned scraper definition) |
| Run it over every product URL at a fixed time | a batch or a scheduled pipeline |
| Know when the run has finished | a signed webhook |
| Store observations, detect changes, alert | your code and your database |
ExtractHub has no built-in “price dropped” alert. It gives you clean, typed rows per URL with a status and an error code, and your code decides what counts as a change. That split is deliberate: only you know whether a 1% drop matters, which currency to convert to, or who to notify.
Step 1: a product extractor with typed prices
Start with the fields a comparison needs, and nothing else:
nameandsku: identify the product and prove the page parsed.price: a number, not the display text.currency: so a price in another currency is not read as a change.availability: an out-of-stock product is a different event from a price change.
Many product pages carry a schema.org Product block in JSON-LD, which is a steadier source than the visible layout. An illustrative extractor config for such a page:
{
"sourceType": "html",
"fields": [
{ "name": "name", "selector": "script[type=\"application/ld+json\"]", "extract": "jsonContent", "jsonPaths": ["name"], "required": true },
{ "name": "sku", "selector": "script[type=\"application/ld+json\"]", "extract": "jsonContent", "jsonPaths": ["sku"] },
{ "name": "price", "selector": "script[type=\"application/ld+json\"]", "extract": "jsonContent", "jsonPaths": ["offers.price"], "transforms": ["toNumber"] },
{ "name": "currency", "selector": "script[type=\"application/ld+json\"]", "extract": "jsonContent", "jsonPaths": ["offers.priceCurrency"] },
{ "name": "availability", "selector": "script[type=\"application/ld+json\"]", "extract": "jsonContent", "jsonPaths": ["offers.availability"] }
]
}
A few details decide whether this works on a given site:
offerscan be an array. When a page lists several offers,offers.pricefinds nothing; useoffers[0].priceinstead. Look at the JSON in a saved copy of the page before you choose the path.- A
jsonPathsfield reads the first matching script. If the page has aBreadcrumbListorOrganizationblock before theProductblock, make the selector more specific. - Keep
toNumberon the price even when the JSON looks numeric: some sites write"price": "49.90"as a string, and the transform makes both cases a number. availabilitystays a string such as"https://schema.org/InStock". Map it to in stock / out of stock in your code; there is no transform for it, and the raw value keeps states such asPreOrdervisible.
When the page has no structured data, read the visible price with extract: "textContent" and extractPrice, not toNumber. toNumber returns null for "$1,299.00" because of the currency symbol; extractPrice finds the number and works out the decimal mark. For availability, point a selector at the element that signals the state and use extract: "exists". The post on cleaning scraped data has the full table of number transforms.
Which fields to make required
A top-level field with required: true fails the request with 422 required_fields_missing when its final value is empty (null, "" or []). That is what you want for a field that proves the page parsed, and the wrong thing for a field that is legitimately empty.
The price is the classic trap. An out-of-stock product often shows no price at all. With a required price, every such product becomes a failed URL, and when the page was fetched through a scraping provider that failure is charged like a success. Make name (or sku) required, keep price optional, and let your code read “page parsed, no price” as its own state.
Release and pin a major version
Release the extractor and call it by a major pin such as @you/example-product@1. A selector fix released as 1.0.1 then reaches the next daily run without touching your monitor, while a change of output shape (a new type, a removed field) needs a new major and cannot break you by surprise. If a public extractor for your target site already exists in the catalog, you can pin that one instead of writing your own.
Step 2: run the price monitoring scraper every day
There are two ways to run the same extractor on a schedule. Pick by the number of products and by whether you already run a scheduler.
| Batch from your scheduler | Scheduled pipeline | |
|---|---|---|
| URLs per run | up to 1000 per batch | up to 100 saved start URLs (via MCP) |
| Who triggers it | your cron, CI job or worker | ExtractHub’s scheduler |
| Per-URL results | NDJSON lines with status and error code | dataset records + download link |
| Webhook | batch.completed / batch.failed / batch.paused | completed / failed |
Option A: a daily batch
Your scheduler submits one batch per day. An illustrative example:
curl -X POST "https://api.extracthub.io/api/extractor/batch" \
-H "X-API-Key: $EXTRACTHUB_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: prices-2026-11-29" \
-d '{
"extractor_id": "@you/example-product@1",
"targets": [
{ "url": "https://www.example.com/p/1001" },
{ "url": "https://www.example.com/p/1002" }
],
"webhook_url": "https://hooks.example.com/extracthub",
"webhook_events": ["batch.completed", "batch.failed"],
"metadata": { "monitor": "prices", "day": "2026-11-29" }
}'
Build the Idempotency-Key from the date. If your scheduler retries the submit, the same key returns the existing batch instead of starting (and paying for) a second run that day. The pin is resolved once at submission, so every product in the run is read by the same version, and the batch status reports which one in extractor_version. Store it with each observation: when a number looks odd, you know which release produced it.
The answer is a 202 with a batch_id. The batch API post covers status polling, paging and how credit is held.
Option B: a scheduled pipeline
If you would rather not run a scheduler at all, save the product URLs on a one-step pipeline and give it a cron. With the ExtractHub MCP server connected, an agent sends something like:
{
"name": "Daily prices",
"input_urls": ["https://www.example.com/p/1001", "https://www.example.com/p/1002"],
"steps": [{ "extractor_id": "@you/example-product@1" }],
"limits": { "maxCostPerRun": 2, "maxRunsPerDay": 2 },
"schedule": { "cronExpression": "0 6 * * *", "timezone": "UTC", "isActive": true },
"webhook": { "url": "https://hooks.example.com/extracthub" }
}
The schedule stays off unless isActive is true, and maxCostPerRun stops a run that would spend more than you planned. The scheduled scraping post covers the cron fields, timezones and the cases where a run is skipped.
Detail pages or list pages?
Each URL is one charged request, so the cheapest monitor reads the fewest pages. When a category page already shows the price of every product on it, one list extractor over that page replaces dozens of product page requests. The trade-off: list pages often lack the SKU or the stock state. A common split is a list page for the price, then a batch of product pages only for the items whose list price changed.
Step 3: know when the run is done
Do not poll on a timer. When the batch ends, your webhook URL receives a batch.completed (or batch.failed) event with the counts, your metadata and the results_url. It never contains the scraped data. The request carries X-Webhook-Signature: t=<unix seconds>,v1=<hex>, an HMAC-SHA256 of <t>.<raw body> with the signing secret from the API keys page. Check it, answer with a 2xx right away, and deduplicate on X-Webhook-Id, since a failed delivery is retried.
Then read the results: one NDJSON line per URL, in the order of your targets, paged with a cursor until the X-Next-Cursor header disappears. Results are kept for 7 days after the batch ended, so a receiver that was down for a day can still catch up.
Step 4: detect price changes in your code
A result line looks like this (illustrative values, trimmed; cost elided):
{"index":0,"url":"https://www.example.com/p/1001","status":"succeeded","result":{"extracted":{"name":"Example kettle","sku":"EX-1001","price":39.9,"currency":"USD","availability":"https://schema.org/InStock"}},"cost":…}
{"index":1,"url":"https://www.example.com/p/1002","status":"failed","error":{"code":"http_404","message":"The target page returned HTTP 404"},"cost":…}
The important decision is what each line means for your stored price. A failed scrape is not a price of zero, and a missing price is not a price drop. Classify every line before you compare anything:
// Turn one batch result line into an observation. `previous` is the last stored one for this URL.
export function toObservation(line, previous, observedAt) {
if (line.status === "succeeded") {
const { price, currency, availability } = line.result.extracted;
const inStock = typeof availability === "string" && availability.endsWith("/InStock");
const obs = { url: line.url, observedAt, state: price == null ? "no_price" : "ok", price, currency, inStock };
obs.changed =
previous?.state === "ok" && obs.state === "ok" &&
(previous.price !== price || previous.currency !== currency);
return obs;
}
const code = line.error?.code;
if (code === "http_404" || code === "http_410") return { url: line.url, observedAt, state: "gone" };
// required_fields_missing, upstream_error, upstream_timeout, other target statuses:
// the price is unknown today. Keep the previous price; do not record a change.
return { url: line.url, observedAt, state: "unknown", errorCode: code };
}
Some rules this encodes:
- Compare only two
okobservations. A change fromunknownto a price is the scraper recovering, not the shop changing its price. - A currency change is its own event. If the site starts serving another currency, compare after conversion or flag it, but do not report it as a price move.
goneneeds confirmation. A 404 on one day can be a short glitch on the shop’s side. Mark the product removed after it is gone on two runs in a row.- Store every observation, not only changes. A history of
unknowndays on one product is the first sign that its page changed.
The index field maps each line back to your targets, so you can join on your own product id without matching URLs.
Keep the monitor healthy
A price monitor fails quietly: the page layout changes, the price field comes back empty, and your chart flattens. Three habits catch it:
- Watch the share of
unknownandno_priceper run. A jump on one day across many products points at the extractor, not at the shop. - Use the extractor’s health checks. Released versions are probed on a test URL and marked degraded or broken when their required fields come back empty; the scraper monitoring post explains how. Because
nameis required, a broken layout shows up there. - Fix forward with a patch. Release the corrected selectors as a patch of the same major, and the next run picks them up through the
@1pin.
What a run costs
Every URL is charged at its tier: a plain direct fetch, a fetch through the scraping proxy, or a JavaScript-rendered fetch. Product pages that carry their price in the HTML or in JSON-LD rarely need JavaScript rendering, and if the site serves them without the proxy, useProxy: false puts each URL on the cheapest tier, where a failed request is free. A URL fetched through the proxy is charged in full once the request reached the scraping provider, also when it fails. Work out one run’s cost on a small batch, multiply by the runs per month, and check the tiers on the pricing section.
Before the first live run, a test key (exth_test_...) runs the same batch calls without fetching anything or moving credit, which is enough to build the webhook receiver and the result reader.
Let an agent build it
The extractor builder skill writes the product extractor, checks it on a saved page and releases it. Install it in Claude Code:
git clone https://github.com/extracthub-io/extracthub-extractor-builder ~/.claude/skills/extracthub-extractor-builder
Ask for “a price monitoring extractor for this product page: name, SKU, price as a number, currency and availability”. The agent skill page lists what it does.
FAQ
How do I build a price monitoring scraper?
Write one extractor for the product page that returns the price as a number, the currency and the availability, release it, then run it over your product URLs every day with a batch or a scheduled pipeline. Store each result and compare it with the previous one in your own code.
Should the price field be required in a price scraper?
Usually not. A product that is out of stock often shows no price, and a required price would turn that normal state into a failed request. Make the product name or SKU required to prove the page parsed, and keep the price optional.
How often should a price monitoring scraper run?
As often as the price can change in a way you act on, and no more: every run is charged per URL. Work out the cost of one run on a small batch first, then multiply it by the runs per month.
Can a price monitoring scraper alert me when a price drops?
ExtractHub has no built-in price drop alert. It returns typed rows per URL with a status and an error code, and a signed webhook tells you when the run is done; your code compares each price with the last one and sends the alert.
How do I tell a removed product from a failed scrape?
Look at the error code of each URL. In a batch, a page that answered 404 or 410 fails with http_404 or http_410, while a page that loaded but did not parse fails with required_fields_missing. Record the first as a removed product and the second as an unknown price.
Related
- Build a job listings scraper: list pages, JobPosting JSON and dedupe by URL: Build a job listings scraper that returns structured JSON: job URLs from list pages, JobPosting fields and ISO dates from each job page, and dedupe by URL.
- Use ready-made web scrapers instead of writing one: find, check and pin a public extractor: Use ready-made web scrapers instead of writing one: find a public extractor, read its fields, price tier and health, pin a version and call it with your key.
- How to scrape infinite scroll pages: window scroll, inner panels and load more buttons: How to scrape infinite scroll pages: look for pagination first, then use scroll_to_bottom on the window or an inner panel, bound it, and test the rendered DOM.
- Agent skill: install the extractor builder skill for Claude Code
- MCP server: connect Claude Code, Cursor or any MCP client
- API reference: realtime extract, async jobs and the Batch API
- Web scraper catalog: public extractors you can call today