DEV Community

Алексей Спинов
Алексей Спинов

Posted on

How to Monitor Competitor Websites for Changes Automatically

Want to know when a competitor changes their pricing, adds a product, or updates their website? Here is how to set up automatic monitoring.

The Architecture

Scraper → Hash/Diff → Database → Alert (email/Slack)
Enter fullscreen mode Exit fullscreen mode

Simple Change Detector

const crypto = require("crypto");
const fs = require("fs");

async function checkForChanges(url, name) {
  const res = await fetch(url, { headers: { "User-Agent": "Monitor/1.0" } });
  const html = await res.text();
  const hash = crypto.createHash("md5").update(html).digest("hex");

  const file = `hashes/${name}.txt`;
  const prevHash = fs.existsSync(file) ? fs.readFileSync(file, "utf8") : "";

  if (hash !== prevHash) {
    console.log(`CHANGED: ${name}`);
    fs.writeFileSync(file, hash);
    // Send alert here
    return true;
  }
  return false;
}
Enter fullscreen mode Exit fullscreen mode

Monitor Specific Elements

const cheerio = require("cheerio");

async function monitorPrice(url, selector) {
  const res = await fetch(url);
  const $ = cheerio.load(await res.text());
  const currentPrice = $(selector).text().trim();

  // Compare with stored price
  const stored = getStoredPrice(url);
  if (stored && stored !== currentPrice) {
    alert(`Price changed: ${stored}${currentPrice}`);
  }
  storePrice(url, currentPrice);
}
Enter fullscreen mode Exit fullscreen mode

Run on Schedule

# Check every 6 hours
0 */6 * * * node /path/to/monitor.js
Enter fullscreen mode Exit fullscreen mode

What to Monitor

  • Competitor pricing pages
  • Product catalogs (new products)
  • Job listings (hiring = growing)
  • Blog posts (content strategy)
  • Social media follower counts

Resources


Need competitor monitoring set up? $50-100. Automated alerts when anything changes. Email: Spinov001@gmail.com | Hire me

Top comments (0)