Blog

Manga downloader: cannot connect to chrome at 127.0.0.1

Manga downloader: cannot connect to chrome at 127.0.0.1

Este error:

j@furin ~/Documents/ocio/software/Manga_downloader % python main.py                                                                                                      [1]
[INFO](undetected_chromedriver.patcher) 2023-04-30 12:41:23 : patching driver executable /home/j/.local/share/undetected_chromedriver/77b221ac36856c4a_chromedriver
Traceback (most recent call last):
  File "/mnt/hayai/Documents/ocio/software/Manga_downloader/main.py", line 45, in <module>
    downloader = Downloader(**settings)
  File "/mnt/hayai/Documents/ocio/software/Manga_downloader/downloader.py", line 67, in __init__
    self.init_function()
  File "/mnt/hayai/Documents/ocio/software/Manga_downloader/downloader.py", line 118, in init_function
    self.get_driver()
  File "/mnt/hayai/Documents/ocio/software/Manga_downloader/downloader.py", line 93, in get_driver
    self.driver = uc.Chrome(options=option)
  File "/home/j/.local/lib/python3.10/site-packages/undetected_chromedriver/__init__.py", line 409, in __init__
    super(Chrome, self).__init__(
  File "/home/j/.local/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    super().__init__(
  File "/home/j/.local/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 106, in __init__
    super().__init__(
  File "/home/j/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 288, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/j/.local/lib/python3.10/site-packages/undetected_chromedriver/__init__.py", line 602, in start_session
    super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session(
  File "/home/j/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 381, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/j/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 444, in execute
    self.error_handler.check_response(response)
  File "/home/j/.local/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:42027
from unknown error: unable to discover open pages
Stacktrace:
#0 0x55b269352fe3 <unknown>
#1 0x55b269091d36 <unknown>
#2 0x55b2690bf48c <unknown>
#3 0x55b2690b6352 <unknown>
#4 0x55b2690f8af7 <unknown>
#5 0x55b2690f811f <unknown>
#6 0x55b2690ef693 <unknown>
#7 0x55b2690c203a <unknown>
#8 0x55b2690c317e <unknown>
#9 0x55b269314dbd <unknown>
#10 0x55b269318c6c <unknown>
#11 0x55b2693224b0 <unknown>
#12 0x55b269319d63 <unknown>
#13 0x55b2692ecc35 <unknown>
#14 0x55b26933d138 <unknown>
#15 0x55b26933d2c7 <unknown>
#16 0x55b26934b093 <unknown>
#17 0x7fef0d8adbb5 <unknown>

Se solventa actualizando selenium:

j@furin ~/Documents/ocio/software/Manga_downloader % pip install undetected-chromedriver --upgrade                                                                                                      [1]
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: undetected-chromedriver in /home/j/.local/lib/python3.10/site-packages (3.1.6)
Collecting undetected-chromedriver
  Downloading undetected-chromedriver-3.4.6.tar.gz (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.3/61.3 kB 1.7 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Requirement already satisfied: selenium>=4.0.0 in /home/j/.local/lib/python3.10/site-packages (from undetected-chromedriver) (4.6.0)
Requirement already satisfied: requests in /usr/lib/python3.10/site-packages (from undetected-chromedriver) (2.28.2)
Requirement already satisfied: websockets in /home/j/.local/lib/python3.10/site-packages (from undetected-chromedriver) (10.4)
Requirement already satisfied: urllib3[socks]~=1.26 in /usr/lib/python3.10/site-packages (from selenium>=4.0.0->undetected-chromedriver) (1.26.13)
Requirement already satisfied: trio-websocket~=0.9 in /home/j/.local/lib/python3.10/site-packages (from selenium>=4.0.0->undetected-chromedriver) (0.9.2)
Requirement already satisfied: trio~=0.17 in /home/j/.local/lib/python3.10/site-packages (from selenium>=4.0.0->undetected-chromedriver) (0.22.0)
Requirement already satisfied: certifi>=2021.10.8 in /usr/lib/python3.10/site-packages (from selenium>=4.0.0->undetected-chromedriver) (2022.12.7)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3.10/site-packages (from requests->undetected-chromedriver) (3.4)
Requirement already satisfied: async-generator>=1.9 in /home/j/.local/lib/python3.10/site-packages (from trio~=0.17->selenium>=4.0.0->undetected-chromedriver) (1.10)
Requirement already satisfied: sniffio in /home/j/.local/lib/python3.10/site-packages (from trio~=0.17->selenium>=4.0.0->undetected-chromedriver) (1.3.0)
Requirement already satisfied: attrs>=19.2.0 in /usr/lib/python3.10/site-packages (from trio~=0.17->selenium>=4.0.0->undetected-chromedriver) (22.2.0)
Requirement already satisfied: exceptiongroup>=1.0.0rc9 in /home/j/.local/lib/python3.10/site-packages (from trio~=0.17->selenium>=4.0.0->undetected-chromedriver) (1.0.3)
Requirement already satisfied: sortedcontainers in /home/j/.local/lib/python3.10/site-packages (from trio~=0.17->selenium>=4.0.0->undetected-chromedriver) (2.4.0)
Requirement already satisfied: outcome in /home/j/.local/lib/python3.10/site-packages (from trio~=0.17->selenium>=4.0.0->undetected-chromedriver) (1.2.0)
Requirement already satisfied: wsproto>=0.14 in /home/j/.local/lib/python3.10/site-packages (from trio-websocket~=0.9->selenium>=4.0.0->undetected-chromedriver) (1.2.0)
Requirement already satisfied: PySocks!=1.5.7,<2.0,>=1.5.6 in /home/j/.local/lib/python3.10/site-packages (from urllib3[socks]~=1.26->selenium>=4.0.0->undetected-chromedriver) (1.7.1)
Requirement already satisfied: h11<1,>=0.9.0 in /home/j/.local/lib/python3.10/site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium>=4.0.0->undetected-chromedriver) (0.14.0)
Building wheels for collected packages: undetected-chromedriver
  Building wheel for undetected-chromedriver (setup.py) ... done
  Created wheel for undetected-chromedriver: filename=undetected_chromedriver-3.4.6-py3-none-any.whl size=44482 sha256=790fea1403e4b4063c01e724ecc325e374943c6dc3e49f8509db444f669e8eb9
  Stored in directory: /home/j/.cache/pip/wheels/1a/d3/1e/5c4db53aad550b49a3e4ffaf37f455957787336abf88a21523
Successfully built undetected-chromedriver
Installing collected packages: undetected-chromedriver
  Attempting uninstall: undetected-chromedriver
    Found existing installation: undetected-chromedriver 3.1.6
    Uninstalling undetected-chromedriver-3.1.6:
      Successfully uninstalled undetected-chromedriver-3.1.6
Successfully installed undetected-chromedriver-3.4.6

Ahora funciona bien:

j@furin ~/Documents/ocio/software/Manga_downloader % python main.py                                                                                                      [0]
[INFO](undetected_chromedriver.patcher) 2023-04-30 13:43:38 : patching driver executable /home/j/.local/share/undetected_chromedriver/undetected_chromedriver
[INFO](root) 2023-04-30 13:43:39 : Find action class, use BookwalkerJP class.
[INFO](root) 2023-04-30 13:43:39 : Login...
[INFO](root) 2023-04-30 13:43:44 : Login finished...
[INFO](root) 2023-04-30 13:43:44 : Starting download manga 1, imgdir: /mnt/hayai/Documents/ocio/img/_manga/bookwalker/yamada_kun_en/05
[INFO](root) 2023-04-30 13:43:44 : Loading Book page...
[INFO](root) 2023-04-30 13:43:52 : Book page Loaded...
[INFO](root) 2023-04-30 13:43:52 : Preparing for downloading...
[INFO](root) 2023-04-30 13:44:12 : Run before downloading...
[INFO](root) 2023-04-30 13:44:12 : Start download...
[INFO](root) 2023-04-30 13:44:12 : Has 194 pages.
[INFO](root) 2023-04-30 13:44:15 : Page 1 Downloaded
[...]