Created
January 29, 2023 23:35
-
-
Save mattsegura/9138e3178c501c62180df461e109019d to your computer and use it in GitHub Desktop.
Monitor Flipper zero website for restock on product
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import time, random | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.3' | |
} | |
def check_product_status(): | |
url = "https://shop.flipperzero.one/collections/flipper-zero-accessories/products/wifi-devboard" | |
response = requests.get(url, headers=headers) | |
soup = BeautifulSoup(response.text, "html.parser") | |
button = soup.find("button", {"class": "btn product-form__cart-submit"}) | |
if button: | |
in_stock = button.find("span").text.strip() != "Sold out" | |
if in_stock: | |
print("Product is in stock!") | |
send_notification() | |
else: | |
print("Product is out of stock.") | |
else: | |
print("Button element not found.") | |
def send_notification(message): | |
# Code to send an email or SMS notification to the user | |
pass | |
if __name__ == "__main__": | |
while True: | |
check_product_status() | |
time.sleep(random.uniform(30, 60)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment