Closed
Description
Hello!
I am trying to execute the code in the Google Colab environment, but I get an error. My code:
!pip install -U seleniumbase
from seleniumbase import Driver
driver = Driver(uc=True, headless=True)
try:
driver.open("https:/www.investmint.ru/")
driver.sleep(10)
finally:
driver.quit()
print('driver:\n',driver.page_source)
Error:
---------------------------------------------------------------------------
WebDriverException Traceback (most recent call last)
[<ipython-input-60-bd9a82e05721>](https://localhost:8080/#) in <cell line: 8>()
6 # driver = Driver(uc=True, chromium_arg="--no-sandbox,--headless,--disable-gpu") # Методы driver: https://github.com/seleniumbase/SeleniumBase/issues/2200
7 #driver = Driver(uc=True, chromium_arg="--no-sandbox,--disable-dev-shm-usage,--disable-application-cache,--disable-setuid-sandbox,--disable-browser-side-navigation,--disable-save-password-bubble,--disable-single-click-autofill,--allow-file-access-from-files,--disable-prompt-on-repost,--dns-prefetch-disable,--disable-translate,--disable-renderer-backgrounding,--disable-backgrounding-occluded-windows,--disable-client-side-phishing-detection,--disable-oopr-debug-crash-dump,--disable-top-sites,--ash-no-nudges,--no-crash-upload,--deny-permission-prompts,--disable-popup-blocking,--homepage=chrome://new-tab-page/,--headless=new,--remote-debugging-host=127.0.0.1,--remote-debugging-port=9222,--user-data-dir=/tmp/tmpemr44m_f,--lang=es-ES,--no-default-browser-check,--no-first-run,--no-service-autorun,--password-store=basic,--log-level=0")
----> 8 driver = Driver(uc=True)
9
10 try:
10 frames
[/usr/local/lib/python3.10/dist-packages/seleniumbase/plugins/driver_manager.py](https://localhost:8080/#) in Driver(browser, headless, headless2, headed, locale_code, protocol, servername, port, proxy, proxy_bypass_list, proxy_pac_url, multi_proxy, agent, cap_file, cap_string, recorder_ext, disable_js, disable_csp, enable_ws, disable_ws, enable_sync, use_auto_ext, undetectable, uc_cdp_events, uc_subprocess, log_cdp_events, no_sandbox, disable_gpu, incognito, guest_mode, dark_mode, devtools, remote_debug, enable_3d_apis, swiftshader, ad_block_on, host_resolver_rules, block_images, do_not_track, chromium_arg, firefox_arg, firefox_pref, user_data_dir, extension_zip, extension_dir, disable_features, binary_location, driver_version, page_load_strategy, use_wire, external_pdf, is_mobile, mobile, d_width, d_height, d_p_r, uc, undetected, uc_cdp, uc_sub, log_cdp, wire, pls)
527 from seleniumbase.core import browser_launcher
528
--> 529 driver = browser_launcher.get_driver(
530 browser_name=browser_name,
531 headless=headless,
[/usr/local/lib/python3.10/dist-packages/seleniumbase/core/browser_launcher.py](https://localhost:8080/#) in get_driver(browser_name, headless, locale_code, use_grid, protocol, servername, port, proxy_string, proxy_bypass_list, proxy_pac_url, multi_proxy, user_agent, cap_file, cap_string, recorder_ext, disable_js, disable_csp, enable_ws, enable_sync, use_auto_ext, undetectable, uc_cdp_events, uc_subprocess, log_cdp_events, no_sandbox, disable_gpu, headless2, incognito, guest_mode, dark_mode, devtools, remote_debug, enable_3d_apis, swiftshader, ad_block_on, host_resolver_rules, block_images, do_not_track, chromium_arg, firefox_arg, firefox_pref, user_data_dir, extension_zip, extension_dir, disable_features, binary_location, driver_version, page_load_strategy, use_wire, external_pdf, test_id, mobile_emulator, device_width, device_height, device_pixel_ratio, browser)
1654 )
1655 else:
-> 1656 return get_local_driver(
1657 browser_name,
1658 headless,
[/usr/local/lib/python3.10/dist-packages/seleniumbase/core/browser_launcher.py](https://localhost:8080/#) in get_local_driver(browser_name, headless, locale_code, servername, proxy_string, proxy_auth, proxy_user, proxy_pass, proxy_bypass_list, proxy_pac_url, multi_proxy, user_agent, recorder_ext, disable_js, disable_csp, enable_ws, enable_sync, use_auto_ext, undetectable, uc_cdp_events, uc_subprocess, log_cdp_events, no_sandbox, disable_gpu, headless2, incognito, guest_mode, dark_mode, devtools, remote_debug, enable_3d_apis, swiftshader, ad_block_on, host_resolver_rules, block_images, do_not_track, chromium_arg, firefox_arg, firefox_pref, user_data_dir, extension_zip, extension_dir, disable_features, binary_location, driver_version, page_load_strategy, use_wire, external_pdf, mobile_emulator, device_width, device_height, device_pixel_ratio)
3562 uc_path = LOCAL_UC_DRIVER
3563 uc_path = os.path.realpath(uc_path)
-> 3564 driver = undetected.Chrome(
3565 options=chrome_options,
3566 user_data_dir=user_data_dir,
[/usr/local/lib/python3.10/dist-packages/seleniumbase/undetected/__init__.py](https://localhost:8080/#) in __init__(self, options, user_data_dir, driver_executable_path, browser_executable_path, port, enable_cdp_events, log_level, headless, patch_driver, version_main, patcher_force_close, suppress_welcome, use_subprocess, debug, **kw)
310 if hasattr(service_, "creation_flags"):
311 setattr(service_, "creation_flags", creationflags)
--> 312 super().__init__(options=options, service=service_)
313 self.reactor = None
314 if enable_cdp_events:
[/usr/local/lib/python3.10/dist-packages/selenium/webdriver/chrome/webdriver.py](https://localhost:8080/#) in __init__(self, options, service, keep_alive)
43 options = options if options else Options()
44
---> 45 super().__init__(
46 browser_name=DesiredCapabilities.CHROME["browserName"],
47 vendor_prefix="goog",
[/usr/local/lib/python3.10/dist-packages/selenium/webdriver/chromium/webdriver.py](https://localhost:8080/#) in __init__(self, browser_name, vendor_prefix, options, service, keep_alive)
64
65 try:
---> 66 super().__init__(command_executor=executor, options=options)
67 except Exception:
68 self.quit()
[/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py](https://localhost:8080/#) in __init__(self, command_executor, keep_alive, file_detector, options)
206 self._authenticator_id = None
207 self.start_client()
--> 208 self.start_session(capabilities)
209
210 def __repr__(self):
[/usr/local/lib/python3.10/dist-packages/seleniumbase/undetected/__init__.py](https://localhost:8080/#) in start_session(self, capabilities)
468 if not capabilities:
469 capabilities = self.options.to_capabilities()
--> 470 super().start_session(capabilities)
471
472 def quit(self):
[/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py](https://localhost:8080/#) in start_session(self, capabilities)
290
291 caps = _create_caps(capabilities)
--> 292 response = self.execute(Command.NEW_SESSION, caps)["value"]
293 self.session_id = response.get("sessionId")
294 self.caps = response.get("capabilities")
[/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py](https://localhost:8080/#) in execute(self, driver_command, params)
345 response = self.command_executor.execute(driver_command, params)
346 if response:
--> 347 self.error_handler.check_response(response)
348 response["value"] = self._unwrap_value(response.get("value", None))
349 return response
[/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/errorhandler.py](https://localhost:8080/#) in check_response(self, response)
227 alert_text = value["alert"].get("text")
228 raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here
--> 229 raise exception_class(message, screen, stacktrace)
WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:9222
from chrome not reachable
Stacktrace:
#0 0x5d1b4c1b3dc3 <unknown>
#1 0x5d1b4bea2337 <unknown>
#2 0x5d1b4be8d599 <unknown>
#3 0x5d1b4bedb982 <unknown>
#4 0x5d1b4bed243d <unknown>
#5 0x5d1b4bf1b7f0 <unknown>
#6 0x5d1b4bf0f1f3 <unknown>
#7 0x5d1b4bee028a <unknown>
#8 0x5d1b4bee0c5e <unknown>
#9 0x5d1b4c1780eb <unknown>
#10 0x5d1b4c17c03b <unknown>
#11 0x5d1b4c164201 <unknown>
#12 0x5d1b4c17cba2 <unknown>
#13 0x5d1b4c1490bf <unknown>
#14 0x5d1b4c1a2f18 <unknown>
#15 0x5d1b4c1a30f0 <unknown>
#16 0x5d1b4c1b2f14 <unknown>
#17 0x783ad5f8cac3 <unknown>
Please help!