diff --git a/docs/source/jobs.rst b/docs/source/jobs.rst index 5b1ad934..1c17f6ae 100644 --- a/docs/source/jobs.rst +++ b/docs/source/jobs.rst @@ -97,6 +97,8 @@ Job-specific optional keys: - ``useragent``: ``User-Agent`` header used for requests (otherwise browser default is used) - ``browser``: Either ``chromium``, ``chrome``, ``chrome-beta``, ``msedge``, ``msedge-beta``, ``msedge-dev``, ``firefox``, ``webkit`` (must be installed with ``playwright install``) +- ``executable_path``: Path to a custom browser executable to launch instead of the + bundled Playwright build (for example a specific Firefox build); combine with ``browser`` - ``ignore_http_error_codes``: List of HTTP errors to ignore (see :ref:`advanced_topics`) Because this job uses Playwright_ to diff --git a/lib/urlwatch/jobs.py b/lib/urlwatch/jobs.py index 87e6e09a..13c299f2 100644 --- a/lib/urlwatch/jobs.py +++ b/lib/urlwatch/jobs.py @@ -435,7 +435,7 @@ class BrowserJob(Job): __required__ = ('navigate',) - __optional__ = ('wait_until', 'wait_for', 'useragent', 'browser', 'ignore_http_error_codes') + __optional__ = ('wait_until', 'wait_for', 'useragent', 'browser', 'executable_path', 'ignore_http_error_codes') def get_location(self): return self.user_visible_url or self.navigate @@ -446,7 +446,8 @@ def set_base_location(self, location): def retrieve(self, job_state): from playwright.sync_api import sync_playwright with sync_playwright() as playwright: - browser = playwright[self.browser or "chromium"].launch() + launch_kwargs = {'executable_path': self.executable_path} if self.executable_path else {} + browser = playwright[self.browser or "chromium"].launch(**launch_kwargs) page = browser.new_page(user_agent=self.useragent) if self.wait_until in ('networkidle0', 'networkidle2'):