From 9d742446ab294be437b14a5737e3be19032345cc Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 25 May 2022 11:05:18 +0200 Subject: [PATCH] Playwright - ByPass CSP for more reliable JS scraping, disable accept downloads --- changedetectionio/content_fetcher.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index 194b3e06..af082a95 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -277,8 +277,13 @@ class base_html_playwright(Fetcher): # Use the default one configured in the App.py model that's passed from fetch_site_status.py context = browser.new_context( user_agent=request_headers['User-Agent'] if request_headers.get('User-Agent') else 'Mozilla/5.0', - proxy=self.proxy + proxy=self.proxy, + # This is needed to enable JavaScript execution on GitHub and others + bypass_csp=True, + # Should never be needed + accept_downloads=False ) + page = context.new_page() try: # Bug - never set viewport size BEFORE page.goto