AI agents and automation
Price monitoring with AI agents and CAPTCHAs
A price monitor sounds simple: visit pages, read prices, compare. In practice shop pages vary, change often and sit behind bot checks. This article lays out an architecture in which an agent helps where it is strong and plain code handles the rest.
What the system has to do
A monitoring job for public prices has five duties: decide which pages to check and when, load each page reliably, get past any challenge on the way, extract the price and availability correctly, and tell someone when something meaningful changes. A model can help with two of these, extraction and occasional repair. The rest is ordinary engineering, and keeping it ordinary is what makes the system cheap to run.
The use case is price intelligence on public product pages: your own listings across marketplaces, competitors' public prices, or supplier catalogues. It does not involve logging into anyone else's account.
The architecture at a glance
| Component | Responsibility | Model involved? |
|---|---|---|
| Scheduler | Queues URLs by priority and interval | No |
| Fetcher | Loads pages with HTTP or a browser pool | No |
| Challenge handler | Detects CAPTCHAs and calls the solving API | No |
| Extractor | Reads structured data, then selectors, then a model | Fallback only |
| Validator | Checks plausibility against history | No |
| Alerter | Sends changes that pass thresholds | Optional, for summaries |
Scheduling pages sensibly
Not every product needs the same frequency. Fast moving items may deserve a check every few hours, a long tail of stable items once a day. A priority queue keyed by the next due time handles this well. Spread checks for the same shop across the interval instead of starting them all at midnight; bursts are what trigger rate limits and CAPTCHAs. The request queue page covers the pattern.
Fetching: HTTP first, browser when needed
Many shops render prices in the initial HTML or expose them in a JSON request the page makes. Fetch those with an HTTP client; it is fast and cheap. Use a browser pool only for shops whose prices appear after JavaScript runs. Record per shop which method works, so the fetcher does not guess each time.
Keep sessions sticky per shop: one cookie jar and one outgoing IP for a batch of pages. Shops that see a returning session challenge it less, and cookie based clearances stay valid for the whole batch.
Handling challenges in the fetch layer
Shop pages meet several kinds of checks, and each has a recognizable signature. The challenge handler looks for these after each fetch and resolves them before the page goes further.
- Cloudflare interstitial. A 403 or 503 with Cloudflare markers. Create an
AntiCloudflareTaskwith the page URL and the same proxy the fetcher uses, then store thecf_clearancecookie with the returned User-Agent for the batch. - AWS WAF. A 405 response with a
gokuPropsobject. Request anAntiAwsWafTaskProxyLesstask and set the returned value as theaws-waf-tokencookie. - DataDome slider. A redirect to the slider page. Send a
DatadomeSliderTaskwith the blocked URL, the slider URL and your proxy, then use thedatadomecookie. - Form widgets. Rare on product pages but common on store locators and stock checkers. reCAPTCHA and Turnstile tokens go into the form or request the page sends.
def on_challenge(kind: str, page_url: str, proxy: str | None, extra: dict) -> dict:
"""Return the task to send for a detected challenge (illustrative)."""
if kind == "cloudflare_page":
return {"type": "AntiCloudflareTask", "websiteURL": page_url, "proxy": proxy}
if kind == "aws_waf":
return {"type": "AntiAwsWafTaskProxyLess", "websiteURL": page_url}
if kind == "datadome":
return {"type": "DatadomeSliderTask", "websiteURL": page_url,
"captchaUrl": extra["slider_url"], "proxy": proxy}
raise ValueError(f"no handler for {kind}")
Because the cookie types are valid for many follow-up requests, the cost per product page is a fraction of the per solve price. AWS WAF runs at $1.40 per 1,000 solves and the Cloudflare challenge at $0.84; one solve often clears a whole batch for that shop.
Extraction in three tiers
Try the cheap and exact methods first, and fall back to a model only when they fail.
- Structured data. Many shops embed schema.org Product data with
offers.priceandpriceCurrency. Read it first. - Per shop selectors. A small selector map per domain handles the rest of the well behaved shops.
- Model fallback. When both fail, send trimmed page text and a schema (title, price, currency, availability) to a model. If it succeeds repeatedly for one shop, ask it to propose a selector so the next run does not need it.
This is the place where an agent pays off: unknown shops, redesigns and messy layouts. Elsewhere, code is faster and more exact. Our article on how AI agents are used in web scraping covers extraction in more detail.
Validate before you alert
False alerts erode trust in a monitor faster than missed ones. Validate each reading: price positive and in the expected currency, change within a sane range of the last reading (a 90 percent drop is more likely a parsing error than a sale), and availability consistent with the page. Store suspicious readings, re-check them on the next cycle, and alert only when the second reading agrees.
Alerting and summaries
Alerts should be short: product, old price, new price, link, time. A model can turn a day's changes into a readable summary for a team channel, which is a good low risk use of language models because a person reads the result.
Operating costs and monitoring
Track four numbers per shop: pages fetched, challenges met, solves made, and extraction fallbacks to the model. A rise in challenges usually means pacing or IP issues; a rise in fallbacks means a redesign. Both are signals to adjust before the bill grows. A balance funded from $40 covers every challenge type, and failed solves are free.
Scope of a fair monitor
Monitor public pages only, keep request rates modest, and respect explicit restrictions. Price monitoring is a well established business practice, but it does not need personal data, logins to other people's accounts or aggressive crawling. Our note on e-commerce scraping and CAPTCHAs covers shop specific challenges further.
Handling shop redesigns
Shops redesign product pages without notice, and a monitor finds out when extraction suddenly fails for every page of one domain. Treat that as an event rather than as a stream of errors. When the failure rate for a shop crosses a threshold within one cycle, pause further fetches for that shop, send a few sample pages to the model fallback, and ask it to propose new selectors. Test the proposal against the samples, store it if it works, and resume. A person reviews the change the next morning. This keeps the monitor running through most redesigns and avoids fetching thousands of pages that would all fail the same way.
Keeping history useful
Store every validated reading with its timestamp, source URL and extraction method. History is what makes validation possible, and it answers questions later: did the price change, or did our parser? Keep raw HTML for a short window as well, so a disputed reading can be checked against the page it came from.
Common questions
Does a price monitor need an AI agent at all?
Not for well structured shops. The agent is most useful for unknown or messy pages and for repairing extraction after a redesign.
How often should product pages be checked?
It depends on how fast prices move. A few hours for volatile items and once a day for stable ones is a common starting point.
Is one Cloudflare cookie enough for many pages?
Often yes, for the same site, IP and User-Agent, until it expires. That makes the cost per page much lower than the per solve price.
How do I avoid false price alerts?
Validate readings against history and re-check suspicious changes on the next cycle before sending an alert.
Can the monitor log into competitor accounts for member prices?
No. Monitoring is for public pages and your own accounts; logging into other people's accounts is outside our terms.
Keep reading
- Price monitoringTracking public prices across many shops on a schedule, matching the same product between them and spotting changes.
- CAPTCHAs in e-commerce scrapingWhere online stores place CAPTCHAs, how catalogue crawls and price checks differ, and patterns that keep both running with few challenges.
- AWS WAF solver$1.40 per 1,000 tasks, answers under 3 seconds.
- How AI agents are used in web scrapingWhere language model agents genuinely help a scraper, from planning crawls to messy extraction and selector repair, and where they fall short.