Please help me write a simple python code to check newegg stock for specifically the MSI…
- User
Please help me write a simple python code to check newegg stock for specifically the MSI GeForce RTX™ 5060 Ti 8G CYCLONE OC every 15 minutes. Thank you
Assistant
Here's a simple Python script that checks the stock status of the MSI GeForce RTX™ 5060 Ti 8G CYCLONE OC on Newegg every 15 minutes. It uses
requestsandBeautifulSoupto scrape the product page and determine if the item is in stock.⚠️ Note: As of now (April 2025), the RTX 5060 Ti may not be released yet, so this example assumes you already have the correct product URL from Newegg. If it doesn't exist yet, you can test with another GPU model like the RTX 4060 or similar.
✅ Requirements
Install the necessary packages:
pip install requests beautifulsoup4
🧾 Example Code
import time import requests from bs4 import BeautifulSoup # Replace this URL with the actual product page for the MSI GeForce RTX 5060 Ti 8G CYCLONE OC when available PRODUCT_URL = "https://www.newegg.com/msi-geforce-rtx-5060-ti-rtx5060ti-8g-cyclone-oc/p/N82E16814127594" HEADERS = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0 Safari/537.36" } def check_stock(): try: response = requests.get(PRODUCT_URL, headers=HEADERS) soup = BeautifulSoup(response.text, 'html.parser') # Look for the "Add to Cart" button as a sign of stock availability add_to_cart_button = soup.find("button", {"class": "btn btn-primary btn-lg btn-block btn-add-to-cart"}) if add_to_cart_button and "disabled" not in add_to_cart_button.attrs: print("[✅ IN STOCK] MSI GeForce RTX 5060 Ti 8G CYCLONE OC is available!") else: print("[❌ OUT OF STOCK] Not available yet.") except Exception as e: print(f"[⚠️ ERROR] Could not check stock: {e}") if __name__ == "__main__": print("Starting Newegg stock checker...") while True: check_stock() print("Waiting 15 minutes before next check...\n") time.sleep(15 * 60) # 15 minutes in seconds
🔍 How This Works
- The script fetches the product page.
- It searches for the "Add to Cart" button.
- If the button is found and not disabled, the item is likely in stock.
- It repeats every 15 minutes.
📝 Tips
- Make sure the URL points to the exact product page once it becomes available.
- You can enhance this by adding email or push notifications when in stock.
- Consider using an API like newegg-scraper or browser extensions if scraping gets blocked.
Would you like me to help you add notifications via email or phone (Pushover) when it's back in stock?