Skip to content

Instantly share code, notes, and snippets.

@pa-0
Forked from mhsmathew/basic-scraping.py
Created July 6, 2026 23:52
Show Gist options
  • Select an option

  • Save pa-0/caefd60f3da647abe3272f1b6b8a71e9 to your computer and use it in GitHub Desktop.

Select an option

Save pa-0/caefd60f3da647abe3272f1b6b8a71e9 to your computer and use it in GitHub Desktop.
Basic web scraping monitor
import requests
from bs4 import BeautifulSoup
import time
def update():
request = requests.get('https://mathewsteininger.com/sample-product')
html = request.content
soup = BeautifulSoup(html, 'html.parser')
# Monitor this tag to check stock changes
stock = soup.find("button", {"id": "availability"})
# Monitor this tag to check price changes
price = soup.find("div", {"id": "price"})
return stock, price
stock, price = update()
while True:
time.sleep(2)
updated_stock, updated_price = update()
if (stock, price) != (updated_stock, updated_price):
# Could connect notification API here
print("Price or Stock Changed!")
stock, price = updated_stock, updated_price
else:
print("No Update")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment