@sportik174

Как использовать undetected-chromedriver с wsl?

WSL: Ubuntu 22.04
Python: 3.10
Google Chrome (установлен в WSL): 109.0.5414.74
undetected-chromedriver: 3.2.1

Код взят из документации для чистоты эксперимента:
import undetected_chromedriver as uc


def main():
    options = uc.ChromeOptions()
    options.add_argument('--headless')
    chrome = uc.Chrome(options=options)
    chrome.get('https://datadome.co/customers-stories/toppreise-ends-web-scraping-and-content-theft-with-datadome/')
    chrome.save_screenshot('datadome_undetected_webddriver.png')

if __name__ == '__main__':
    main()


Ошибка:
Traceback (most recent call last):
  File "/mnt/c/Users/hasen/Desktop/GIT/undetected-chromedriver-wsl/main.py", line 14, in <module>
    main()
  File "/mnt/c/Users/hasen/Desktop/GIT/undetected-chromedriver-wsl/main.py", line 7, in main
    chrome = uc.Chrome(options=options)
  File "/mnt/c/Users/hasen/Desktop/GIT/undetected-chromedriver-wsl/env/lib/python3.10/site-packages/undetected_chromedriver/__init__.py", line 431, in __init__
    super(Chrome, self).__init__(
  File "/mnt/c/Users/hasen/Desktop/GIT/undetected-chromedriver-wsl/env/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    super().__init__(
  File "/mnt/c/Users/hasen/Desktop/GIT/undetected-chromedriver-wsl/env/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 106, in __init__
    super().__init__(
  File "/mnt/c/Users/hasen/Desktop/GIT/undetected-chromedriver-wsl/env/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 288, in __init__
    self.start_session(capabilities, browser_profile)
  File "/mnt/c/Users/hasen/Desktop/GIT/undetected-chromedriver-wsl/env/lib/python3.10/site-packages/undetected_chromedriver/__init__.py", line 693, in start_session
    super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session(
  File "/mnt/c/Users/hasen/Desktop/GIT/undetected-chromedriver-wsl/env/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 381, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/mnt/c/Users/hasen/Desktop/GIT/undetected-chromedriver-wsl/env/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 444, in execute
    self.error_handler.check_response(response)
  File "/mnt/c/Users/hasen/Desktop/GIT/undetected-chromedriver-wsl/env/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 249, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:57126
from chrome not reachable
Stacktrace:
#0 0x7f103bef6303 <unknown>
#1 0x7f103bccabbd <unknown>
#2 0x7f103bcb95ab <unknown>
#3 0x7f103bcf73c3 <unknown>
#4 0x7f103bceeae9 <unknown>
#5 0x7f103bd304a6 <unknown>
#6 0x7f103bd27753 <unknown>
#7 0x7f103bcfaa14 <unknown>
#8 0x7f103bcfbb7e <unknown>
#9 0x7f103bf4532e <unknown>
#10 0x7f103bf48c0e <unknown>
#11 0x7f103bf2b610 <unknown>
#12 0x7f103bf49c23 <unknown>
#13 0x7f103bf1d545 <unknown>
#14 0x7f103bf6a6a8 <unknown>
#15 0x7f103bf6a836 <unknown>
#16 0x7f103bf85d13 <unknown>
#17 0x7f103b264b43 <unknown>
  • Вопрос задан
  • 407 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы