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.
-
Create a virtual environment and install dependencies
python3 -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt
-
Create your
.envfilecp .env.example .env
Edit
.envand 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 oftenrunre-checks all products (default3600= 1 hour).DATABASE_PATH— SQLite file location (defaultprice_tracker.db).
Never commit
.env— only.env.exampleshould be tracked.
All commands are run from inside price_tracker/:
cd price_trackerAdd 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 checkRun continuously, checking every CHECK_INTERVAL_SECONDS:
python main.py runscraper.pyfetches 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 returnsNone(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.pystores each tracked product and every price observation in SQLite (productsandprice_historytables).notifier.pysends 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.
- 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_SELECTORSinscraper.py.