diff --git a/src/flaresolverr_service.py b/src/flaresolverr_service.py index 6cc5ff9..5541242 100644 --- a/src/flaresolverr_service.py +++ b/src/flaresolverr_service.py @@ -251,7 +251,7 @@ def _resolve_challenge(req: V1RequestBase, method: str) -> ChallengeResolutionT: def click_verify(driver: WebDriver): try: - logging.debug("Try to find the Cloudflare verify checkbox") + logging.debug("Try to find the Cloudflare verify checkbox...") iframe = driver.find_element(By.XPATH, "//iframe[@title='Widget containing a Cloudflare security challenge']") driver.switch_to.frame(iframe) checkbox = driver.find_element( @@ -263,14 +263,14 @@ def click_verify(driver: WebDriver): actions.move_to_element_with_offset(checkbox, 5, 7) actions.click(checkbox) actions.perform() - logging.debug("Cloudflare verify checkbox found and clicked") - except Exception: - logging.debug("Cloudflare verify checkbox not found on the page") + logging.debug("Cloudflare verify checkbox found and clicked!") + except Exception as e: + logging.debug("Cloudflare verify checkbox not found on the page. Error: " + str(e)) finally: driver.switch_to.default_content() try: - logging.debug("Try to find the Cloudflare 'Verify you are human' button") + logging.debug("Try to find the Cloudflare 'Verify you are human' button...") button = driver.find_element( by=By.XPATH, value="//input[@type='button' and @value='Verify you are human']", @@ -280,10 +280,9 @@ def click_verify(driver: WebDriver): actions.move_to_element_with_offset(button, 5, 7) actions.click(button) actions.perform() - logging.debug("The Cloudflare 'Verify you are human' button found and clicked") + logging.debug("The Cloudflare 'Verify you are human' button found and clicked!") except Exception as e: - logging.debug("The Cloudflare 'Verify you are human' button not found on the page") - # print(e) + logging.debug("The Cloudflare 'Verify you are human' button not found on the page. Error: " + str(e)) time.sleep(2) @@ -298,7 +297,8 @@ def _evil_logic(req: V1RequestBase, driver: WebDriver, method: str) -> Challenge if method == 'POST': _post_request(req, driver) else: - driver.get(req.url) + with driver: + driver.get(req.url) # set cookies if required if req.cookies is not None and len(req.cookies) > 0: @@ -310,7 +310,8 @@ def _evil_logic(req: V1RequestBase, driver: WebDriver, method: str) -> Challenge if method == 'POST': _post_request(req, driver) else: - driver.get(req.url) + with driver: + driver.get(req.url) # wait for the page if utils.get_config_log_html(): @@ -429,4 +430,5 @@ def _post_request(req: V1RequestBase, driver: WebDriver): """ - driver.get("data:text/html;charset=utf-8," + html_content) + with driver: + driver.get("data:text/html;charset=utf-8," + html_content) diff --git a/src/utils.py b/src/utils.py index 2517970..79cf6f6 100644 --- a/src/utils.py +++ b/src/utils.py @@ -135,9 +135,6 @@ def get_webdriver(proxy: dict = None) -> WebDriver: # https://github.com/microsoft/vscode/issues/127800#issuecomment-873342069 # https://peter.sh/experiments/chromium-command-line-switches/#use-gl options.add_argument('--use-gl=swiftshader') - # workaround for updated 'verify you are human' check - # https://github.com/FlareSolverr/FlareSolverr/issues/811 - options.add_argument('--auto-open-devtools-for-tabs') proxy_extension_dir = None if proxy and all(key in proxy for key in ['url', 'username', 'password']):