19 lines
725 B
Python
19 lines
725 B
Python
|
from playwright.sync_api import sync_playwright, expect, Page, BrowserContext
|
||
|
from playwright_stealth import stealth_sync
|
||
|
from pyvirtualdisplay.smartdisplay import SmartDisplay
|
||
|
|
||
|
|
||
|
def create_display(vnc=False) -> SmartDisplay:
|
||
|
if vnc:
|
||
|
return SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=2345, color_depth=24)
|
||
|
return SmartDisplay(size=(1920, 1080))
|
||
|
|
||
|
|
||
|
def start_browser(name: str) -> (Page, BrowserContext):
|
||
|
p = sync_playwright().start()
|
||
|
browser = p.firefox.launch_persistent_context(f"./data/{name}/", headless=False, args=["--start-maximised"],
|
||
|
no_viewport=True)
|
||
|
page = browser.new_page()
|
||
|
stealth_sync(page)
|
||
|
return page, browser
|