A Pyton script that allows you to track the price of your favorite Amazon product and send you an email when the desired price is reached
- Install pyhton 3
- Use the package manager pip to install the modules.
pip install requests pip install smtplib pip install bs4 pip install email
you have to modify some variables for the script to work well, first modify the url variable by putting the link of your favorite productfrom amazon and the variable MY_USER_AGENT by putting your user agent (search on Google : "My user agent")
extracted from the sendmail() function
SMTP_HOST = "smtp.gmail.com" # smtp server
SMTP_PORT = 587 # smtp server port
# Authentication of your smtp server
MAIL_ADDRESS = ""
PASSWORD = ""
FROM = MAIL_ADDRESS # YOUR MAIL ADDRESS
TO = MAIL_ADDRESS # you can use a LIST type or STRING type
-
for the SMTP_HOST variable it is the DNS of the smtp (Simple Mail Transfer Protocol) server and for SMTP_PORT it is the port where it will listen by default I used port 587 (TLS,Transport Layer Security) which will allow to encrypt the communication between client-server. for more information about this port : Transport Layer Security
-
you must then modify the variables MAIL_ADDRESS and PASSWORD, to connect to the smtp server, if you do not want to put your real password I know that for Google we can generate passwords for applications, for more informations click here : App passwords
to finish you just have to modify the FROM and TO variables for sending mail, for the TO variable you can use a list if you want to send to several people (ex : [[email protected], [email protected]])
instead of using this command
python .\amazon-price-tracking.py
it's better to run your script regularly and automatically on your computer, for Linux there is a crontab command, for Windows I don't know any particular command but I've seen that Scheduled Tasks can do the job.