diff --git a/Amazon Wishlist Notifier/script.py b/Amazon Wishlist Notifier/script.py index aabd54560d..1896482140 100644 --- a/Amazon Wishlist Notifier/script.py +++ b/Amazon Wishlist Notifier/script.py @@ -12,6 +12,7 @@ WISHLIST_URL = 'https://www.amazon.com/gp/registry/wishlist/YOUR_WISHLIST_ID' CHECK_INTERVAL = 3600 # Check every hour + def get_wishlist_items(): headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3" @@ -28,7 +29,8 @@ def get_wishlist_items(): price_element = item.find('span', class_='a-offscreen') price = price_element.get_text().strip() if price_element else "Price not available" availability = "In stock" if "In Stock" in item.get_text() else "Out of stock" - wishlist.append({'name': name, 'price': price, 'availability': availability}) + wishlist.append({'name': name, 'price': price, + 'availability': availability}) return wishlist @@ -36,6 +38,7 @@ def get_wishlist_items(): print("Failed to retrieve wishlist data from Amazon.") return [] + def send_email(subject, message): msg = MIMEText(message) msg['Subject'] = subject @@ -48,6 +51,7 @@ def send_email(subject, message): server.sendmail(SENDER_EMAIL, RECIPIENT_EMAIL, msg.as_string()) server.quit() + def main(): while True: wishlist_items = get_wishlist_items() @@ -66,5 +70,6 @@ def main(): time.sleep(CHECK_INTERVAL) + if __name__ == "__main__": main()