diff --git a/app/env_config.py b/app/env_config.py index c71fbea..ecd74ba 100644 --- a/app/env_config.py +++ b/app/env_config.py @@ -79,22 +79,11 @@ if match: else: wh_masked_url = "[Invalid webhook URL]" -# HTTP headers +# HTTP headers - natural browser headers HEADERS = { - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", - "Accept": "application/json, text/plain, */*", - "Accept-Language": "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7", - "Accept-Encoding": "gzip, deflate, br, zstd", - "Referer": "https://partners.nvidia.com/", - "Origin": "https://partners.nvidia.com", - "Connection": "keep-alive", - "Sec-Fetch-Dest": "empty", - "Sec-Fetch-Mode": "cors", - "Sec-Ch-Ua": "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not.A/Brand\";v=\"24\"", - "Sec-Ch-Ua-Platform": "\"macOS\"", - "Cache-Control": "no-cache, no-store, must-revalidate", - "Pragma": "no-cache", - "Expires": "0" + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", + "Accept": "application/json", + "Referer": "https://partners.nvidia.com/" } # Load country setting and localization config diff --git a/app/gpu_checker.py b/app/gpu_checker.py index 75713d4..88f5a50 100644 --- a/app/gpu_checker.py +++ b/app/gpu_checker.py @@ -1,6 +1,7 @@ import requests import logging import time +import random from env_config import HEADERS, PRODUCT_NAMES, API_URL_SKU, API_URL_STOCK, PRODUCT_URL from notifier import send_discord_notification, send_out_of_stock_notification, send_sku_change_notification from requests.adapters import HTTPAdapter, Retry @@ -22,8 +23,9 @@ def check_rtx_50_founders(): # Fetching nvidia API data try: - cache_buster = int(time.time() * 1000) - sku_url = f"{API_URL_SKU}&_t={cache_buster}" + # Natural cache busting that looks like API versioning + version_param = f"1.{int(time.time() % 10000)}.{random.randint(10, 99)}" + sku_url = f"{API_URL_SKU}&api_version={version_param}" response = session.get(sku_url, timeout=10) logging.info(f"SKU API response: {response.status_code}") @@ -62,8 +64,8 @@ def check_rtx_50_founders(): first_run_dict[product_name] = False # Check product availability in API_URL_STOCK for each SKU - cache_buster = int(time.time() * 1000) - api_stock_url = f"{API_URL_STOCK}{product_sku}&_t={cache_buster}" + version_param = f"1.{int(time.time() % 10000)}.{random.randint(10, 99)}" + api_stock_url = f"{API_URL_STOCK}{product_sku}&api_version={version_param}" logging.info(f"[{product_name}] Checking stock: {api_stock_url}") try: