The Amazon Price Alert project is a Python script designed to monitor the price of a specific product on Amazon. When the price falls below a predetermined threshold, the script automatically sends an email alert to the user. This utility is particularly useful for tracking price drops on desired products, enabling users to make timely purchases at the best possible price.
The primary goal of this project is to automate the process of tracking a product's price on Amazon and to notify the user promptly when the product is available at a lower price.
Regularly checking the price of a product can be tedious and time-consuming. This project simplifies the process by automating the price tracking and notification procedure, ensuring that users don't miss out on potential savings.
- URL and Price Threshold Setup: The user specifies the URL of the Amazon product and the desired buy price threshold in the script.
- Web Scraping: The script uses
requests
andBeautifulSoup
to scrape the product's current price from the Amazon webpage. - Price Comparison: The scraped price is compared with the user-defined threshold.
- Email Alert: If the current price is lower than or equal to the threshold, the script sends an email alert to the user.
- Libraries Used:
requests
: For sending HTTP requests to the Amazon product page.BeautifulSoup
frombs4
: For parsing HTML and extracting the necessary data (product price and title).lxml
: Used as a parser for BeautifulSoup.smtplib
: For sending the email alert.
- Script Flow:
- Setting Up the URL and Headers: The script starts by defining the URL of the product and headers to mimic a browser request.
- HTTP Request: It sends a GET request to the Amazon product page.
- HTML Parsing: The response is parsed to extract the product price and title using BeautifulSoup.
- Price Processing: The price is processed and converted into a floating-point number for comparison.
- Email Notification: If the product's price falls below the threshold, an email is composed and sent using SMTP protocol.
- Replace
URL
,BUY_PRICE
,YOUR_SMTP_ADDRESS
,YOUR_EMAIL
, andYOUR_PASSWORD
with your desired product URL, price threshold, SMTP server address, and email credentials. - Run the script periodically (e.g., using a cron job) to check for price updates.
- Integrate with a scheduling tool for regular checks.
- Extend functionality to monitor multiple products.
- Include error handling for web requests and email sending process.
- Implement a user-friendly interface for non-technical users.
This project is intended for educational purposes. Be aware of Amazon's terms of service regarding web scraping.
Happy Savings!