feat: export build_launch_options helper for composing with existing Playwright instance#255
feat: export build_launch_options helper for composing with existing Playwright instance#255mvanhorn wants to merge 2 commits into
Conversation
…Playwright Closes CloakHQ#153. Adds build_launch_options(headless, proxy, args, stealth_args, timezone, locale, geoip, extension_paths, **kwargs) which returns the kwargs dict that launch() forwards to playwright.chromium.launch(). Callers can now drive their own sync_playwright() instance and pass pw.chromium.launch(**opts), instead of copy-pasting the body of launch() per release. launch() is refactored to delegate to build_launch_options so behavior stays identical. Adds examples/external_playwright.py showing the maintainer reply's pattern (own Playwright + build_launch_options + pw.chromium.launch).
|
Thanks for the PR, @mvanhorn! This addresses #153 nicely. Two things before we can merge:
Let us know if you'd like to update, or we can handle it on our end. |
…a build_launch_options Adds humanize_browser() and humanize_browser_async() helpers so callers who run their own Playwright instance can apply stealth humanize patches. launch_async() now delegates to build_launch_options() to match launch(), eliminating the duplicated geoip/proxy/webrtc/build_args block.
|
Thanks for the careful review. Both items addressed in 17c85c3:
Let me know if you'd prefer a single |
Summary
Users who run their own
sync_playwright()context can now pull CloakBrowser's launch args into it with one call instead of copying the body oflaunch()each release.Why this matters
In #153, @chrisemke described maintaining scrapers that share a single Playwright instance across multiple stealth backends, and asked whether
launch()could accept aplaywrightparam or expose a lower-level helper. The maintainer reply asked the same question.This PR takes the lower-level-helper route to keep the existing
launch()signature stable. Adding aplaywright=kwarg can layer on later if preferred - it composes with this helper.Testing
test_build_args,test_config,test_proxy,test_backend,test_geoip,test_extension_loading.py_compileclean acrosscloakbrowser/browser.py,cloakbrowser/__init__.py,examples/external_playwright.py.build_launch_options()returnsexecutable_path,headless,args,ignore_default_args; adds aproxydict only when a proxy URL is passed.launch()is refactored to delegate tobuild_launch_options(), so the existing call path produces identical kwargs forpw.chromium.launch().examples/external_playwright.pyshows thesync_playwright() + build_launch_options()pattern from the maintainer reply.Scope kept to the sync path. Async
launch_async,launch_context,launch_persistent_contextare untouched and can follow as a separate PR if useful.Fixes #153