From 8e2403a7da1ee61c64ed55cdbb935a5307ea5afe Mon Sep 17 00:00:00 2001 From: "Arno.Edwards" <138990495+Umpire2018@users.noreply.github.com> Date: Wed, 1 Jan 2025 18:37:50 +0800 Subject: [PATCH] fix(browser)!: default to Chromium channel for new headless mode (#387) BREAKING CHANGE: Updated `chrome_channel` to "chromium" to fix compatibility with the new Chromium headless implementation. This resolves the error `playwright._impl._errors.Error: BrowserType.launch: Chromium distribution 'chrome' is not found`, caused by the removal of the old headless mode in Chromium. With this change, channels like "chrome" and "msedge" now default to the new headless mode, aligning with upstream updates in Playwright v1.49. The new headless mode uses the real Chrome browser, offering more authenticity, reliability, and feature parity with the full browser. Additionally, simplified fallback logic by directly assigning `chrome_channel` based on `browser_type` or defaulting to "chromium". Refer to: - https://playwright.dev/python/docs/browsers#chromium - https://github.com/microsoft/playwright/issues/33566 --- crawl4ai/async_configs.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/crawl4ai/async_configs.py b/crawl4ai/async_configs.py index 4d85bc8f..acec8a9a 100644 --- a/crawl4ai/async_configs.py +++ b/crawl4ai/async_configs.py @@ -77,7 +77,7 @@ class BrowserConfig: use_managed_browser: bool = False, use_persistent_context: bool = False, user_data_dir: str = None, - chrome_channel: str = "chrome", + chrome_channel: str = "chromium", proxy: str = None, proxy_config: dict = None, viewport_width: int = 1080, @@ -107,14 +107,10 @@ class BrowserConfig: self.use_managed_browser = use_managed_browser self.use_persistent_context = use_persistent_context self.user_data_dir = user_data_dir - if self.browser_type == "chromium": - self.chrome_channel = "chrome" - elif self.browser_type == "firefox": - self.chrome_channel = "firefox" - elif self.browser_type == "webkit": - self.chrome_channel = "webkit" - else: - self.chrome_channel = chrome_channel or "chrome" + + # Directly assign browser_type to chrome_channel, with fallback to default + self.chrome_channel = chrome_channel or self.browser_type or "chromium" + self.proxy = proxy self.proxy_config = proxy_config self.viewport_width = viewport_width