Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Amazon Price Tracker

Monitors Amazon product URLs, checks their price on a schedule, stores price history in SQLite, and emails you when a price drops to or below a target you set.

Setup

  1. Create a virtual environment and install dependencies

    python3 -m venv venv
    source venv/bin/activate      # Windows: venv\Scripts\activate
    pip install -r requirements.txt
  2. Create your .env file

    cp .env.example .env

    Edit .env and fill in:

    • SMTP_EMAIL / SMTP_PASSWORD — a Gmail address and an App Password (not your normal Gmail password; requires 2-Step Verification enabled).
    • ALERT_EMAIL — where alerts get sent by default.
    • CHECK_INTERVAL_SECONDS — how often run re-checks all products (default 3600 = 1 hour).
    • DATABASE_PATH — SQLite file location (default price_tracker.db).

    Never commit .env — only .env.example should be tracked.

Usage

All commands are run from inside price_tracker/:

cd price_tracker

Add a product to track:

python main.py add "https://www.amazon.com/dp/EXAMPLE" 49.99 --email you@example.com

--email is optional and falls back to ALERT_EMAIL from .env.

Run a single check cycle over all tracked products (useful for testing or for running via cron/Task Scheduler instead of the built-in loop):

python main.py check

Run continuously, checking every CHECK_INTERVAL_SECONDS:

python main.py run

How it works

  • scraper.py fetches each product page with a realistic browser User-Agent and parses out the title and price with BeautifulSoup. It tries several fallback CSS selectors for price since Amazon's markup varies by product/region, and returns None (without crashing) if the page is out of stock, blocks the request, or the layout has changed.
  • When checking multiple products, a random 2-5 second delay is added between requests.
  • database.py stores each tracked product and every price observation in SQLite (products and price_history tables).
  • notifier.py sends a plain-text email via Gmail SMTP when a checked price is at or below the product's target.
  • Failed requests or unexpected errors for one product are logged and skipped — they don't stop the rest of the check cycle.

Notes

  • Amazon's HTML changes frequently and scraping may violate Amazon's Terms of Service — this project is intended for personal, low-volume use.
  • If prices stop being detected, inspect the target page's HTML and update PRICE_SELECTORS in scraper.py.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages