import requests import time import os # Read from environment, default to HF Spaces port API_URL = os.getenv("API_URL", "http://127.0.0.1:7860/scrape") API_KEY = os.getenv("API_KEY", "my_secret_key_123") SITES = [ ("🟢 No CF (httpbin)", "https://httpbin.org/headers"), ("🟡 Medium CF (G2.com)", "https://www.g2.com"), ("🔴 Strict CF", "https://nowsecure.nl"), ("🔴 Turnstile Demo", "https://demo.turnstile.workers.dev/"), ("🟡 Indeed (job site)", "https://www.indeed.com"), ] print("\n" + "="*62) print(" 🔬 LIVE 3-STAGE BYPASS TEST — 5 REAL SITES") print("="*62) results = [] for label, url in SITES: print(f"\n {label}") print(f" URL: {url[:55]}") print(f" {'─'*52}") try: headers = {"X-API-Key": API_KEY} resp = requests.post(API_URL, json={"url": url}, headers=headers, timeout=60).json() stage = resp.get("stage", "?") method = resp.get("method", "?") t = resp.get("time_seconds", "?") cookies = resp.get("cookies", {}) token = resp.get("token") html = (resp.get("html") or "")[:80].replace("\n", " ") print(f" ✅ Stage {stage}: {method}") print(f" ⏱ Time: {t}s") print(f" 🍪 Cookies: {len(cookies)}" + (f" 🔑 Token: {token[:25]}..." if token else "")) print(f" 📄 Preview: {html}...") results.append((label, "✅ PASS", stage, t)) except Exception as e: print(f" ❌ FAILED — {str(e)[:80]}") results.append((label, "❌ FAIL", "—", "—")) print("\n" + "="*62) print(" 📊 SUMMARY TABLE") print("="*62) print(f" {'Site':<28} {'Result':<10} {'Stage':<8} {'Time'}") print(f" {'─'*28} {'─'*10} {'─'*8} {'─'*8}") for label, result, stage, t in results: print(f" {label:<28} {result:<10} {str(stage):<8} {t}s") wins = sum(1 for _, r, _, _ in results if "PASS" in r) print(f"\n Score: {wins}/5 sites bypassed") print("="*62)