A simple Python script that scrapes the current price of a specified Amazon product and sends you an email alert when the price drops below your target.
- Fetches the live price of an Amazon product page
- Compares against a user‑specified target price
- Sends an email notification via Gmail SMTP when the price falls below the target
- Python 3.7+
- A Gmail account (for SMTP alerts)
- An Amazon product URL
- Clone this repository
git clone https://github.com/<your‑username>/amazon-price-tracker.git cd amazon-price-tracker
- Create & edit a .env file In the project root, create a file named .env containing:
MY_EMAIL=your‑[email protected]
MY_PASSWORD=your‑gmail‑app‑password- MY_EMAIL: the Gmail address you’ll send from (and to)
- MY_PASSWORD: an App Password generated in your Google Account (not your regular login password)
- Run the script
python main.py- Enter your target price when prompted:
What your tagert price for that product? : 120 - The script will:
- Scrape the current price from the Amazon product page
- If the price is lower than your target, send an email to your MY_EMAIL
- Change product URL
In main.py, update the Product_URL constant to any Amazon product page URL.
- Modify headers If scraping fails, you can adjust the headers dict to mimic a different browser or locale.
- Load environment variables via python-dotenv.
- Fetch page HTML using requests with custom headers.
- Parse price with BeautifulSoup, extracting the element with class a-offscreen.
- Compare the scraped price (float) to your entered target.
- Send email using Gmail’s SMTP server if the condition is met.
License
This project is open‑source and free to use under the MIT License.