A Python app that tracks an Amazon product and send you an e-mail when it price falls down.
It uses some basic web scraping and e-mail sending knowledges.
In this case, we are checking for when the Oculus Rift S is gonna be priced lower that 400€ on Amazon.
- Python3+ (https://www.python.org/downloads/)
- Install required Python packages :
pip install -r requirements.txt
If you wish to use this app :
- Add the url for the product you wish to track here :
URL = 'https://amzn.to/3jV41Tc'
It doesn't have to be an Amazon product, but the program might not work with other websites depending on the id values they use for the name and price of their products. So feel free to change the title
and price
variables values to match the id used on the website of your choice. Also don't forget to change the price treshold for the one that you want in the if condition : if(converted_price < 400):
- Replace my user agent with yours here :
headers = {"User-Agent": 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0'}
To find your user agent, just google my user agent
and simply copy the result.
- Replace the server infos with the ones that suit your e-mail account here :
server = smtplib.SMTP('smtp.gmail.com', 587)
For example, with an hotmail account you would use smtplib.SMTP('smtp.live.com', 587)
.
- Replace my server logins info with yours here :
server.login('[email protected]', 'hbilikxwpkrofbej')
The password I used is a generated one with Google App passwords. If you use a gmail address, you can generate one yourself here : https://bit.ly/2TOr47J
. Otherwise, just use your usual e-mail account password.
- Last but not least for the mailing to work, simply replace my e-mail address with yours here :
server.sendmail('[email protected]', '[email protected]', msg)
First line is the sender e-mail address, second one is the recipient e-mail adress.
- The program will check the price of the desired item every 24h, you can change the value (in seconds) to your convenience here :
time.sleep(86400)
Execute the program this way : python scraper.py
Don't hesitate to experiment with it and have fun !