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:

PartWhere it runs
Read title, SKU, price, currency, availability from a product pagean extractor (a versioned scraper definition)
Run it over every product URL at a fixed timea batch or a scheduled pipeline
Know when the run has finisheda signed webhook
Store observations, detect changes, alertyour 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:

  • name and sku: 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:

  • offers can be an array. When a page lists several offers, offers.price finds nothing; use offers[0].price instead. Look at the JSON in a saved copy of the page before you choose the path.
  • A jsonPaths field reads the first matching script. If the page has a BreadcrumbList or Organization block before the Product block, make the selector more specific.
  • Keep toNumber on 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.
  • availability stays 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 as PreOrder visible.

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 schedulerScheduled pipeline
URLs per runup to 1000 per batchup to 100 saved start URLs (via MCP)
Who triggers ityour cron, CI job or workerExtractHub’s scheduler
Per-URL resultsNDJSON lines with status and error codedataset records + download link
Webhookbatch.completed / batch.failed / batch.pausedcompleted / 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 ok observations. A change from unknown to 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.
  • gone needs 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 unknown days 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:

  1. Watch the share of unknown and no_price per run. A jump on one day across many products points at the extractor, not at the shop.
  2. 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 name is required, a broken layout shows up there.
  3. 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 @1 pin.

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.

All posts