def cloakbrowser_tutorial_job():
results = {
"basic_launch": None,
"advanced_context": None,
"storage_restore": None,
"persistent_profile": None,
"rendered_extraction": None,
"static_parsing": None,
"errors": [],
}
print_section("1. Basic CloakBrowser launch")
Browser = None
try:
"browser = launch"
headless=True,
humanize=True,
args=[
"--no-sandbox",
"--disable-dev-shm-usage",
],
)
page = browser.new_page()
page.goto("https://example.com", wait_until="domcontentloaded", timeout=60000)
The following are results of the search:["basic_launch"] = {
"title": page.title(),
"body_preview": page.locator("body").inner_text(timeout=15000)[:300],
"url": page.url,
}
print(json.dumps(results["basic_launch"], indent=2))
Except Exception As e.
error = {
"section": "basic_launch",
"error": repr(e),
}
The following are results of the search:["errors"].append(error)
print(error)
finally:
safe_close(browser, "basic browser")
print_section("2. Advanced context launch with custom browser context")
No context
try:
context = launch_context(
headless=True,
humanize=True,
viewport={"width": 1365, "height": 768},
locale="en-US",
timezone_id="America/New_York",
color_scheme="light",
extra_http_headers={
"Accept-Language": "en-US,en;q=0.9",
"X-Tutorial-Run": "cloakbrowser-colab",
},
args=[
"--no-sandbox",
"--disable-dev-shm-usage",
],
)
New_page = page()
page.goto(TEST_PAGE_URL, wait_until="domcontentloaded", timeout=60000)
page.locator("#name").fill("CloakBrowser Colab User")
page.locator("#message").fill(
"We are testing safe local browser automation in Google Colab."
)
page.locator("#submit").click()
page.wait_for_timeout(1000)
signals = page.evaluate("() => collectSignals()")
status_text = page.locator("#status").inner_text()
page.screenshot(path=str(SCREENSHOT_PATH), full_page=True)
context.storage_state(path=str(STORAGE_STATE_PATH))
The following are results of the search:["advanced_context"] = {
"status_text": status_text,
"signals": signals,
"screenshot_path": str(SCREENSHOT_PATH),
"storage_state_path": str(STORAGE_STATE_PATH),
}
print(json.dumps(results["advanced_context"], indent=2, default=str))
Except Exception As e.
error = {
"section": "advanced_context",
"error": repr(e),
}
The following are results of the search:["errors"].append(error)
print(error)
finally:
safe_close(context, "advanced context")
print_section("3. Restore localStorage using storage_state")
No restored_context
try:
restored_context = launch_context(
headless=True,
humanize=True,
storage_state=str(STORAGE_STATE_PATH),
viewport={"width": 1365, "height": 768},
locale="en-US",
timezone_id="America/New_York",
args=[
"--no-sandbox",
"--disable-dev-shm-usage",
],
)
restored_page = restored_context.new_page()
restored_page.goto(TEST_PAGE_URL, wait_until="domcontentloaded", timeout=60000)
restored_values = restored_page.evaluate("""
() => ({
tutorial_name: localStorage.getItem("tutorial_name"),
tutorial_message: localStorage.getItem("tutorial_message"),
cloakbrowser_test: localStorage.getItem("cloakbrowser_test")
})
""")
The following are results of the search:["storage_restore"] = restored_values
print(json.dumps(restored_values, indent=2))
Except Exception As e.
error = {
"section": "storage_restore",
"error": repr(e),
}
The following are results of the search:["errors"].append(error)
print(error)
finally:
safe_close(restored_context, "restored context")
Trending
- Build a single-cell RNA-seq analysis pipeline with Scanpy to perform PBMC clustering, annotation, and trajectory discovery
- OpenAI’s AI Agent can now access LinkedIn, Salesforce Gmail and internal tools via sign-in sessions.
- Nick Bostrom Has a Plan for Humanity’s ‘Big Retirement’
- A long shot proposal to protect California workers from AI
- AI Kids’ Toys: The New Wild West
- Natural Language Automatencoders by Anthropic Convert Claude’s internal activations directly into human-readable text explanations
- OpenAI Releases Three Realtime Audio Models: GPT-Realtime-2, GPT-Realtime-Translate, and GPT-Realtime-Whisper in the Realtime API
- LightSeek Foundation releases TokenSpeed, a open-source LLM inference engine targeting TensorRT-LLM level performance for agentic workloads

