Guest User

Untitled

a guest
Jan 24th, 2026
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | Source Code | 0 0
  1. import requests
  2. import time
  3. from datetime import datetime
  4.  
  5. def search_string_in_webpage(url, search_string):
  6.     try:
  7.         response = requests.get(url)
  8.         response.raise_for_status()
  9.         content = response.text
  10.        
  11.         if search_string in content:
  12.             return 1
  13.         else:
  14.             return 0
  15.     except requests.RequestException as e:
  16.         print(f"Error fetching the webpage: {e}")
  17.         return 0
  18.  
  19. url = "https://eu.store.ui.com/eu/en/products/utr"
  20. search_string = "Sold Out"
  21.  
  22. while True:
  23.     result = search_string_in_webpage(url, search_string)
  24.     timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
  25.    
  26.     if result == 1:
  27.         with open("soldout.txt", "a") as f:
  28.             f.write(f"{timestamp}\n")
  29.         print(f"{timestamp} - Found! Logged to soldout.txt")
  30.     else:
  31.         with open("instock.txt", "a") as f:
  32.             f.write(f"{timestamp}\n")
  33.         print(f"{timestamp} - Not found. Logged to instock.txt")
  34.    
  35.     time.sleep(60)
  36.  
Advertisement
Add Comment
Please, Sign In to add comment