diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-01-29 20:37:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-29 20:37:59 +0100 |
commit | 280ddf57b0f54d1805f1ee26aa699469019e731f (patch) | |
tree | cabcbf5fa9a5dbf75a223377dbf032cfeb3e1027 /g4f/webdriver.py | |
parent | Merge pull request #1523 from u66u/which-webdriver (diff) | |
parent | Improve readme / unittests (diff) | |
download | gpt4free-280ddf57b0f54d1805f1ee26aa699469019e731f.tar gpt4free-280ddf57b0f54d1805f1ee26aa699469019e731f.tar.gz gpt4free-280ddf57b0f54d1805f1ee26aa699469019e731f.tar.bz2 gpt4free-280ddf57b0f54d1805f1ee26aa699469019e731f.tar.lz gpt4free-280ddf57b0f54d1805f1ee26aa699469019e731f.tar.xz gpt4free-280ddf57b0f54d1805f1ee26aa699469019e731f.tar.zst gpt4free-280ddf57b0f54d1805f1ee26aa699469019e731f.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/webdriver.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/g4f/webdriver.py b/g4f/webdriver.py index 44765402..d28cd97b 100644 --- a/g4f/webdriver.py +++ b/g4f/webdriver.py @@ -18,6 +18,7 @@ import time from shutil import which from os import path from os import access, R_OK +from .typing import Cookies from .errors import MissingRequirementsError from . import debug @@ -56,9 +57,7 @@ def get_browser( if proxy: options.add_argument(f'--proxy-server={proxy}') # Check for system driver in docker - driver = which('chromedriver') - if not driver: - driver = '/usr/bin/chromedriver' + driver = which('chromedriver') or '/usr/bin/chromedriver' if not path.isfile(driver) or not access(driver, R_OK): driver = None return Chrome( @@ -68,7 +67,7 @@ def get_browser( headless=headless ) -def get_driver_cookies(driver: WebDriver) -> dict: +def get_driver_cookies(driver: WebDriver) -> Cookies: """ Retrieves cookies from the specified WebDriver. @@ -115,8 +114,8 @@ def bypass_cloudflare(driver: WebDriver, url: str, timeout: int) -> None: driver.switch_to.window(window_handle) break + # Click on the challenge button in the iframe try: - # Click on the challenge button in the iframe driver.switch_to.frame(driver.find_element(By.CSS_SELECTOR, "#turnstile-wrapper iframe")) WebDriverWait(driver, 5).until( EC.presence_of_element_located((By.CSS_SELECTOR, "#challenge-stage input")) |