MCPcopy Create free account
hub / github.com/Integuru-AI/Integuru / open_browser_and_wait

Function open_browser_and_wait

create_har.py:6–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5
6async def open_browser_and_wait():
7 async with async_playwright() as p:
8 browser = await p.chromium.launch(headless=False)
9
10 context = await browser.new_context(
11 record_har_path="network_requests.har", # Path to save the HAR file
12 record_har_content="embed", # Omit content to make the HAR file smaller
13 # TODO record_har_url_filter="*", # Optional URL filter
14 )
15
16 page = await context.new_page()
17
18 print(
19 "Browser is open. Press Enter in the terminal when you're ready to close the browser and save cookies..."
20 )
21
22 input("Press Enter to continue and close the browser...")
23
24 # Ensure 2FA is completed before saving cookies
25 cookies = await context.cookies()
26
27 with open("cookies.json", "w") as f:
28 json.dump(cookies, f, indent=4)
29
30 await context.close()
31
32 await browser.close()
33
34asyncio.run(open_browser_and_wait())

Callers 1

create_har.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected