How to build a holiday price tracker in under 100 lines
Holiday sales move fast, and retailers change prices several times a day. In this walkthrough we'll build a small tracker that scrapes a list of product pages, extracts the price as JSON, and sends an alert when it drops below a target.
1. Extract the price as JSON
Instead of writing a selector for each store, ask Quotient for structured output with a schema. The same request works across very different page layouts.
const { data } = await q.scrape(url, {
formats: ["json"],
schema: {
type: "object",
properties: {
name: { type: "string" },
price: { type: "number" },
currency: { type: "string" },
inStock: { type: "boolean" },
},
required: ["name", "price"],
},
});2. Store the history
Any database works. For a weekend project, a single SQLite table with the URL, price and timestamp is enough to draw a chart later.
3. Alert on drops
- Load the last recorded price for each URL
- Compare it to the new price and your target
- Send a message to Slack or email when the new price is lower
“The schema did the heavy lifting. I added three stores without touching the extraction code.”
Sam Rivera
Developer Relations, Quotient