import sys, os, time
from cloakbrowser import launch_context

url = sys.argv[1]
tz = os.environ.get('CLOAKBROWSER_TIMEZONE', 'Europe/Prague')
lc = os.environ.get('CLOAKBROWSER_LOCALE', 'cs-CZ')

ctx = launch_context(
    headless=True,
    timezone=tz,
    locale=lc,
    args=['--no-sandbox', '--disable-dev-shm-usage']
)
page = ctx.new_page()

# Note: we intentionally do NOT set a custom Referer here.
# A self-referring Referer (e.g. /club/hledej -> /club/hledej) triggers
# Cloudflare's bot detection even with CloakBrowser's stealth patches.

try:
    page.goto(url, timeout=30000, wait_until='networkidle')
    print(page.content(), end='')
finally:
    ctx.close()
