Building a Resilient Amazon Stock & Buy-Box Monitor with Cheerio and WhatsApp
How to engineer an automated scraper and availability watcher that parses modern Amazon buy-boxes, bypasses bot blocks, and sends instant WhatsApp alerts.
Building a Resilient Amazon Stock & Buy-Box Monitor
Hunting for limited-stock hardware, collectibles, or flash discounts often feels like an impossible race against scalper bots. Rather than constantly refreshing product tabs, I built an automated tracker in Node.js capable of continuously monitoring multiple Amazon items, parsing dynamic buy-box states, and alerting me instantly via WhatsApp and browser triggers the moment an item becomes available.
Here is a technical walkthrough of how the bot works, how it handles Amazon’s complex DOM variations, and how it delivers zero-latency alerts.
1. Scraping & Parsing the Dynamic Buy-Box
Amazon frequently rotates its buy-box DOM structure between classic table-based layouts and newer flex offer displays. Relying on a naive selector like #add-to-cart-button isn’t enough—especially when trying to avoid overpriced third-party marketplace resellers.
Using Axios and Cheerio, the parser evaluates three critical dimensions:
A. Anti-Bot / Robot Check Detection
Amazon frequently returns HTTP 200 responses containing an interactive CAPTCHA form instead of standard 403 or 429 status codes. Without checking for this, an anti-bot challenge is indistinguishable from an “out of stock” page:
const isBlocked =
$('form[action*="validateCaptcha"]').length > 0 ||
/robot check|captcha/i.test($('title').text());
if (isBlocked) {
return { status: 'blocked', url, seller: null, soldByAmazon: false };
}
B. Purchase Action Determination
The bot checks for multiple purchase flows:
- Direct Add to Cart (
#add-to-cart-button) - Instant Buy Now (
#buy-now-button) - Multiple purchase options (
#buybox-see-all-buying-choices)
C. Distinguishing Official Amazon Stock from Third-Party Resellers
A product might show as “In Stock”, but at double the MSRP from an unauthorized third-party seller. The scraper parses #merchant-info and modern #merchantInfoFeature_feature_div containers:
function parseSeller($) {
// Third-party sellers link to their public storefront profile
const thirdPartyLink = $(
'#sellerProfileTriggerId, #merchant-info a[href*="seller="], #merchantInfoFeature_feature_div a[href*="seller="]'
).first();
if (thirdPartyLink.length > 0) {
return { seller: thirdPartyLink.text().trim() || null, soldByAmazon: false };
}
// Check offer display for direct Amazon fulfillment
const merchantName = $(
'#merchantInfoFeature_feature_div .offer-display-feature-text-message'
).first().text().replace(/\s+/g, ' ').trim();
return {
seller: merchantName,
soldByAmazon: /^amazon\b/i.test(merchantName)
};
}
2. Real-Time WhatsApp Dispatch via Web Session
Push notifications via traditional SMS can be delayed or rack up Twilio costs. For instant, free personal alerts, the bot connects directly to WhatsApp using whatsapp-web.js:
- Terminal QR Authentication: On initial boot,
qrcode-terminalrenders an authentication QR code directly into the terminal window. - Session Persistence: Once paired, WhatsApp Web session cookies are cached locally, allowing subsequent runs to connect silently in the background.
- Dual Dispatching: Alerts are dispatched simultaneously to a personal number or dedicated notification group, along with launching the product URL in the default desktop browser using the
openpackage.
await sendWhatsApp(
`🚨 *Product Available!* 🚨\n\n` +
`*Item:* ${product.name}\n` +
`*Sold by:* ${product.seller || 'Amazon'}\n` +
`*Link:* ${product.url}`
);
Here is an example (AI Generated)

3. Configurable Scheduling & CLI Polish
The watcher is driven by a periodic scheduling loop with customizable polling intervals, randomized jitter to reduce anti-bot fingerprinting, and a polished terminal UI built with @clack/prompts and picocolors:
- Multi-product concurrent monitoring
- Configurable marketplace support (e.g.
.com,.com.mx,.es) - Graceful shutdown handlers cleaning up active Puppeteer and browser processes on
SIGINT
Key Takeaways
- HTTP Status Codes Can Lie: Always inspect HTML contents for hidden CAPTCHAs when scraping protected storefronts.
- Verify the Seller, Not Just Availability: Distinguishing between 1st-party retail and 3rd-party scalpers prevents false alarms.
- Instant Action Hooks: Pairing headless WhatsApp bots with automatic browser tab launching cuts reaction time down to seconds.
You can inspect the full source code and setup instructions on GitHub.