Merge branch 'playwright' of https://github.com/weeix/changedetection.io into playwright

pull/489/head
dgtlmoon 3 years ago
commit 8ce75f40d9

@ -20,6 +20,11 @@ COPY requirements.txt /requirements.txt
RUN pip install --target=/dependencies -r /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 # Final image stage
FROM python:3.8-slim FROM python:3.8-slim

@ -23,7 +23,7 @@ class Fetcher():
content = None content = None
headers = None headers = None
# Will be needed in the future by the VisualSelector, always get this where possible. # Will be needed in the future by the VisualSelector, always get this where possible.
screenshot = None screenshot = False
fetcher_description = "No description" fetcher_description = "No description"
@abstractmethod @abstractmethod
@ -80,6 +80,11 @@ class base_html_playwright(Fetcher):
if os.getenv("PLAYWRIGHT_DRIVER_URL"): if os.getenv("PLAYWRIGHT_DRIVER_URL"):
fetcher_description += " via '{}'".format(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 = '' browser_type = ''
command_executor = '' command_executor = ''
@ -94,7 +99,7 @@ class base_html_playwright(Fetcher):
self.browser_type = os.getenv("PLAYWRIGHT_BROWSER_TYPE", 'chromium').strip('"') self.browser_type = os.getenv("PLAYWRIGHT_BROWSER_TYPE", 'chromium').strip('"')
self.command_executor = os.getenv( self.command_executor = os.getenv(
"PLAYWRIGHT_DRIVER_URL", "PLAYWRIGHT_DRIVER_URL",
'ws://playwright-server:4444/playwright' 'ws://playwright-chrome:3000/playwright'
).strip('"') ).strip('"')
# If any proxy settings are enabled, then we should setup the proxy object # If any proxy settings are enabled, then we should setup the proxy object

@ -24,11 +24,7 @@ services:
# https://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.common.proxy # https://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.common.proxy
# #
# Alternative Playwright URL, do not use "'s or 's! # Alternative Playwright URL, do not use "'s or 's!
# - PLAYWRIGHT_DRIVER_URL=ws://playwright-server:4444/playwright # - PLAYWRIGHT_DRIVER_URL=ws://playwright-chrome:3000/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 proxy settings playwright_proxy_server, playwright_proxy_bypass, playwright_proxy_username, playwright_proxy_password # Playwright proxy settings playwright_proxy_server, playwright_proxy_bypass, playwright_proxy_username, playwright_proxy_password
# #
@ -71,17 +67,11 @@ services:
# - /dev/shm:/dev/shm # - /dev/shm:/dev/shm
# restart: unless-stopped # restart: unless-stopped
# playwright-server: # Used for fetching pages via Playwright+Chrome where you need Javascript support.
# hostname: playwright-server
# build: ./playwright # playwright-chrome:
# environment: # hostname: playwright-chrome
# - PLAYWRIGHT_PORT=4444 # image: browserless/chrome
# # 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
# restart: unless-stopped # restart: unless-stopped
volumes: volumes:

@ -40,4 +40,4 @@ selenium ~= 4.1.0
# need to revisit flask login versions # need to revisit flask login versions
werkzeug ~= 2.0.0 werkzeug ~= 2.0.0
# playwright is installed at Dockerfile build time because it's not available on all platforms # playwright is installed at Dockerfile build time because it's not available on all platforms

Loading…
Cancel
Save