This script tracks the price of a specific product on Amazon and sends an email notification if the price drops below a certain threshold.
- Python 3.x
requests
libraryBeautifulSoup
librarylxml
parsersmtplib
library (for sending emails)- An email account (Gmail) from which the notifications will be sent
- Clone or download the repository to your local machine.
- Install the required libraries using pip:
- Set up your Gmail account to allow less secure apps to access it. You can do this by going to your Google Account settings, then navigate to "Less secure app access" and turn it on.
- Export your email and password as environment variables:
Alternatively, you can directly replace
MY_EMAIL
andMY_PASSWORD
variables in the script with your email and password (not recommended for security reasons).
Replace the url
variable with the URL of the Amazon product you want to track.
Replace the BUY_PRICE
variable with the desired price threshold. You will receive an email notification if the price drops below this value.
Alternatively, you can directly replace MY_EMAIL
and MY_PASSWORD
variables in the script with your email and password (not recommended for security reasons).
- The script sends an HTTP GET request to the Amazon product URL with specific headers to mimic a browser request.
- It then parses the HTML content of the response using BeautifulSoup.
- The script extracts the price of the product from the parsed HTML.
- If the price drops below the specified threshold (
BUY_PRICE
), it sends an email notification using SMTP.
- This script is specifically designed to work with Gmail accounts. If you're using a different email service, you might need to modify the SMTP configuration accordingly.
- Use this script responsibly and avoid spamming Amazon's servers with excessive requests.
- Be cautious about storing your email credentials in plaintext within the script. Consider more secure methods such as environment variables or encrypted storage.