PYTHON AUTOMATION
A Python automation tool that monitors product prices in real-time and sends instant email alerts when deals go live.
This project is designed for smart shoppers and data enthusiasts. By employing Web Scraping techniques, the script periodically checks a specific Amazon product page, extracts the current price, and logs the data. If the price drops below a user-defined threshold, it triggers an SMTP email notification, ensuring you never miss a bargain.
Scrapes live pricing data directly from Amazon product pages.
Sends instant notifications via Gmail when target prices are met.
Maintains a constant CSV history of price fluctuations over time.
Runs automatically at set intervals (e.g., every 24 hours).
We use requests to fetch the page and BeautifulSoup to parse the HTML,
extracting the specific title and price elements.
def check_price():
URL = 'https://a.co/d/5i5wfE2'
headers = {"User-Agent": "Mozilla/5.0..."}
page = requests.get(URL, headers=headers)
soup = BeautifulSoup(page.content, "html.parser")
# Extract title and price
title = soup.find(id="productTitle").get_text()
price = soup.find(id="priceblock_ourprice").get_text()
if(price < 15):
send_mail()
The smtplib library connects to Gmail's SMTP server to send a secure alert when the
logic condition (Price < $15) is met.
def send_mail():
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login('email@gmail.com', 'password')
subject = "The Desk is now less than $15!"
body = "link: https://a.co/d/5i5wfE2"
msg = f"Subject: {subject}\n\n{body}"
server.sendmail('from@gmail.com', 'to@gmail.com', msg)
server.quit()
A simple while loop coupled with time.sleep() keeps the script running
indefinitely, checking prices once a day.
while(True):
check_price()
# Check every 24 hours (86400 seconds)
time.sleep(86400)
This project automates the manual task of price checking, providing a practical application of Python scripting. Key takeaways include: