diff --git a/Dockerfile b/Dockerfile index 2e8131f7e..23a3f2c45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,11 @@ COPY requirements.txt /requirements.txt RUN pip install --target=/dependencies -r /requirements.txt +# Playwright is an alternative to Selenium +# Excluded this package from requirements.txt to prevent arm/v6 and arm/v7 builds from failing +RUN pip install --target=/dependencies playwright~=1.20 \ + || echo "WARN: Failed to install Playwright. The application can still run, but the Playwright option will be disabled." + # Final image stage FROM python:3.8-slim diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index 9e3c5afdb..7c6457b30 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -23,7 +23,7 @@ class Fetcher(): content = None headers = None # Will be needed in the future by the VisualSelector, always get this where possible. - screenshot = None + screenshot = False fetcher_description = "No description" @abstractmethod @@ -80,6 +80,11 @@ class base_html_playwright(Fetcher): if os.getenv("PLAYWRIGHT_DRIVER_URL"): fetcher_description += " via '{}'".format(os.getenv("PLAYWRIGHT_DRIVER_URL")) +# try: +# from playwright.sync_api import sync_playwright +# except ModuleNotFoundError: +# fetcher_enabled = False + browser_type = '' command_executor = '' @@ -94,7 +99,7 @@ class base_html_playwright(Fetcher): self.browser_type = os.getenv("PLAYWRIGHT_BROWSER_TYPE", 'chromium').strip('"') self.command_executor = os.getenv( "PLAYWRIGHT_DRIVER_URL", - 'ws://playwright-server:4444/playwright' + 'ws://playwright-chrome:3000/playwright' ).strip('"') # If any proxy settings are enabled, then we should setup the proxy object diff --git a/docker-compose.yml b/docker-compose.yml index 0914ed6f0..88ee8a761 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,11 +24,7 @@ services: # https://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.common.proxy # # Alternative Playwright URL, do not use "'s or 's! - # - PLAYWRIGHT_DRIVER_URL=ws://playwright-server:4444/playwright - # - # Alternative Playwright Browser Type, must match with PLAYWRIGHT_BROWSER_TYPE in the playwright-server service - # See https://playwright.dev/docs/browsers - # - PLAYWRIGHT_BROWSER_TYPE=chromium + # - PLAYWRIGHT_DRIVER_URL=ws://playwright-chrome:3000/playwright # # Playwright proxy settings playwright_proxy_server, playwright_proxy_bypass, playwright_proxy_username, playwright_proxy_password # @@ -71,17 +67,11 @@ services: # - /dev/shm:/dev/shm # restart: unless-stopped -# playwright-server: -# hostname: playwright-server -# build: ./playwright -# environment: -# - PLAYWRIGHT_PORT=4444 -# # Must match with PLAYWRIGHT_BROWSER_TYPE in the changedetection service -# - PLAYWRIGHT_BROWSER_TYPE=chromium -# ipc: host -# user: pwuser -# security_opt: -# - seccomp:./playwright/seccomp_profile.json + # Used for fetching pages via Playwright+Chrome where you need Javascript support. + +# playwright-chrome: +# hostname: playwright-chrome +# image: browserless/chrome # restart: unless-stopped volumes: diff --git a/requirements.txt b/requirements.txt index 90c53e72c..468dca88f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -40,4 +40,4 @@ selenium ~= 4.1.0 # need to revisit flask login versions werkzeug ~= 2.0.0 -# playwright is installed at Dockerfile build time because it's not available on all platforms \ No newline at end of file +# playwright is installed at Dockerfile build time because it's not available on all platforms