DEV Community

Will
Will

Posted on

I built a zero-dependency competitor price tracker in pure Python (no pip, no API keys)

Most competitor price-monitoring tools charge $40–100/month to watch a handful of URLs. I only wanted to track a few competitors — so I built a small tool I own and run myself. One Python file, no pip install, no API keys, no account.

It's open source (MIT): github.com/willylam2222-bot/priceprobe

Here's how it works and the couple of things that turned out to matter.

The goal

  • Point it at competitor product URLs
  • Get price, stock, and what changed since last run
  • Zero dependencies — runs anywhere Python 3.8+ runs
  • Own it, run it locally, no monthly bill

1. Fetching (the boring part that bites you)

Standard library only — urllib with polite headers, gzip, and retries. The gotcha that cost me time: macOS Python.org builds ship without root certificates, so urlopen throws CERTIFICATE_VERIFY_FAILED on plenty of machines. Rather than make users run "Install Certificates.command", I fall back to an unverified context only after a verified attempt fails — we are reading public product pages, not sending secrets:

contexts = [ssl.create_default_context(), ssl._create_unverified_context()]
for ctx in contexts:
    try:
        with urllib.request.urlopen(req, timeout=20, context=ctx) as r:
            ...
    except urllib.error.URLError as e:
        if not isinstance(getattr(e, "reason", None), ssl.SSLError):
            break  # non-TLS error: unverified will not help
Enter fullscreen mode Exit fullscreen mode

That one fallback is the difference between "works on my machine" and "works on the buyer's machine".

2. Extracting price / stock

A regex that handles the currencies real stores use plus title and stock keywords:

PRICE_RE = re.compile(
    r"(?:S\$|US\$|£|€|\$|USD|SGD|GBP|EUR)\s?\d{1,3}(?:[.,]\d{3})*(?:[.,]\d{2})?", re.I)
OOS_RE = re.compile(r"out[\s-]?of[\s-]?stock|sold[\s-]?out|currently unavailable", re.I)
Enter fullscreen mode Exit fullscreen mode

Per-target custom regex is supported for sites that hide the price somewhere weird.

3. Diffing against the last run

Each run saves a JSON snapshot. The next run compares and flags ▲ price up / ▼ price down (with %) / ✕ out-of-stock / ✓ restock — normalising numbers so £1,299.00 and £1.299,00 compare correctly.

4. A report you would actually send someone

It renders a clean HTML report with changes highlighted.

report

Takeaways

  • Zero-dependency is underrated for tools you want strangers to actually run. No env, no version hell.
  • The TLS-verify fallback removed the #1 support question before it happened.
  • Regex price extraction is "good enough" for a huge share of stores; JS-rendered prices are the long tail.

Try it

Free & open source: github.com/willylam2222-bot/priceprobe — stars welcome ⭐

Not into the terminal? There is a one-time $19 packaged version (double-click runner + step-by-step guide) for non-devs who just want the report: gumroad.com/l/ptzxo. Same engine — you pay for zero setup, not a subscription.

Happy to answer questions about the extraction or diffing logic in the comments.

Top comments (0)