WIP - anti-antibot policies

This commit is contained in:
2025-12-07 17:11:33 +01:00
parent b26a6a2d0a
commit b882240e09
2 changed files with 10 additions and 19 deletions

View File

@@ -79,22 +79,11 @@ if match:
else: else:
wh_masked_url = "[Invalid webhook URL]" wh_masked_url = "[Invalid webhook URL]"
# HTTP headers # HTTP headers - natural browser headers
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", "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, text/plain, */*", "Accept": "application/json",
"Accept-Language": "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7", "Referer": "https://partners.nvidia.com/"
"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"
} }
# Load country setting and localization config # Load country setting and localization config

View File

@@ -1,6 +1,7 @@
import requests import requests
import logging import logging
import time import time
import random
from env_config import HEADERS, PRODUCT_NAMES, API_URL_SKU, API_URL_STOCK, PRODUCT_URL 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 notifier import send_discord_notification, send_out_of_stock_notification, send_sku_change_notification
from requests.adapters import HTTPAdapter, Retry from requests.adapters import HTTPAdapter, Retry
@@ -22,8 +23,9 @@ def check_rtx_50_founders():
# Fetching nvidia API data # Fetching nvidia API data
try: try:
cache_buster = int(time.time() * 1000) # Natural cache busting that looks like API versioning
sku_url = f"{API_URL_SKU}&_t={cache_buster}" 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) response = session.get(sku_url, timeout=10)
logging.info(f"SKU API response: {response.status_code}") logging.info(f"SKU API response: {response.status_code}")
@@ -62,8 +64,8 @@ def check_rtx_50_founders():
first_run_dict[product_name] = False first_run_dict[product_name] = False
# Check product availability in API_URL_STOCK for each SKU # Check product availability in API_URL_STOCK for each SKU
cache_buster = int(time.time() * 1000) version_param = f"1.{int(time.time() % 10000)}.{random.randint(10, 99)}"
api_stock_url = f"{API_URL_STOCK}{product_sku}&_t={cache_buster}" api_stock_url = f"{API_URL_STOCK}{product_sku}&api_version={version_param}"
logging.info(f"[{product_name}] Checking stock: {api_stock_url}") logging.info(f"[{product_name}] Checking stock: {api_stock_url}")
try: try: