Building a Hands-Free Website Monitor with Python

These products have happy customers and reliable expertise. PLUS, GET A 50% DISCOUNT—EXCLUSIVELY AVAILABLE HERE! It costs less than your daily coffee.
Want to Know When a Website Changes? Let Python Do It for You!
Ever found yourself manually checking a website every day just to see if something changed?
Maybe you’re:
Waiting for a product to go back in stock
Tracking a job listing for updates
Watching for a price drop on an item
What if you could stop checking manually and let Python alert you automatically whenever a website changes?
That’s exactly what we’re building today:
A hands-free website monitor that checks a webpage and notifies you when something changes.
Step 1: Install the Required Libraries
Before we start, install these:
pip install requests beautifulsoup4
- requests → Fetches the webpage
- BeautifulSoup → Extracts and compares page content
Step 2: Fetch the Webpage Content
First, we need to load the webpage and store its content:
import requests
URL = "https://example.com" # The website you want to monitor
response = requests.get(URL) # Fetch the webpage
html_content = response.text # Store the HTML
This grabs the entire page as raw HTML.
Step 3: Extract Only the Important Part
Webpages have a lot of extra stuff we don’t need. We use BeautifulSoup to extract only what we care about:
from bs4 import BeautifulSoup
soup = BeautifulSoup(html_content, "html.parser")
# Find the part of the page that changes (e.g., price, stock, text)
target_element = soup.find("div", class_="price") # Change this based on your website
if target_element:
current_value = target_element.text.strip()
else:
current_value = "Not found"
Replace
"div", class_="price"
with the actual HTML tag and class for the element you want to monitor.
Step 4: Save the Initial Value
To check for changes, we need to remember the previous value. Let’s save it:
with open("previous_value.txt", "w") as file:
file.write(current_value)
Step 5: Compare and Send an Alert
Now we check if the value changed and notify you if it did:
import time
while True:
response = requests.get(URL)
soup = BeautifulSoup(response.text, "html.parser")
new_value = soup.find("div", class_="price").text.strip()
# Read the previous value from the file
with open("previous_value.txt", "r") as file:
previous_value = file.read().strip()
if new_value != previous_value:
print(f"
Change detected! New value: {new_value}")
# Update the stored value
with open("previous_value.txt", "w") as file:
file.write(new_value)
time.sleep(60) # Wait 60 seconds before checking again
Now, Python watches the website for you!
- If nothing changes, it keeps checking.
- If the text changes, it alerts you in the terminal.
Step 6: Get Notified on Your Phone or Email
A terminal alert is nice, but why not get a text message or email?
To receive an email notification:
import smtplib
def send_email(message):
sender_email = "your_email@gmail.com"
receiver_email = "your_email@gmail.com"
password = "your_app_password"
with smtplib.SMTP("smtp.gmail.com", 587) as server:
server.starttls()
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, f"Subject: Website Update\n\n{message}")
send_email(f"Website changed! New value: {new_value}")
Now you get an email whenever something changes!
What’s Next? Level Up Your Python Skills
This is just the beginning! You can:
Monitor multiple websites
Send alerts via SMS, Telegram, or Slack
Automate actions when a site updates
Want more real-world Python projects?
Check these out:
Trending Discussions – Stay updated with the latest Python trends
Developer Resources – Tools to build better Python projects
Articles – Guides on real-world Python automation
Now go automate something useful!
Download Free Giveaway Products
We love sharing valuable resources with the community! Grab these free cheat sheets and level up your skills today. No strings attached — just pure knowledge!
More Free Giveaway Products Available Here
- We’ve 15+ Products for FREE, just get it. We’ll promise that you’ll learn something out of each.
For More Learning Purpose
Making extra income by selling websites has never been easier—AI does most of the work for you!
No need to spend hours researching or figuring things out on your own. This step-by-step blueprint gives you everything you need:
A complete guide that walks you through the process
Detailed checklists so you don’t miss a thing
Pre-made ChatGPT prompts to make website creation effortless
It’s all laid out for you—just follow the steps and start earning!