Metadata cannot be written in cache (C:Usersdell25.cacheselenium): アクセスが拒否されました。 (os error 5) The chromedriver version (116.0.5845.96) detected in PATH at C:Usersdell25 } C h C uPython scriptchromedriver.exe might not be compatible with the detected chrome version (121.0.6167.140); currently, chromedriver 121.0.6167.85 is recommended for chrome 121.*, so it is advised to delete the driver in PATH and retry ————————————————————————— WebDriverException Traceback (most recent call last) File ~anaconda3libsite-packagesseleniumwebdrivercommondriver_finder.py:38, in DriverFinder.get_path(service, options) 37 try: —> 38 path = SeleniumManager().driver_location(options) if path is None else path 39 except Exception as err: File ~anaconda3libsite-packagesseleniumwebdrivercommonselenium_manager.py:95, in SeleniumManager.driver_location(self, options) 93 args.append(value) —> 95 output = self.run(args) 97 browser_path = output[“browser_path”] File ~anaconda3libsite-packagesseleniumwebdrivercommonselenium_manager.py:141, in SeleniumManager.run(args) 140 if completed_proc.returncode: –> 141 raise WebDriverException(f”Unsuccessful command executed: {command}.n{result}{stderr}”) 142 return result WebDriverException: Message: Unsuccessful command executed: C:Usersdell25anaconda3libsite-packagesseleniumwebdrivercommonwindowsselenium-manager.exe –browser chrome –output json. {‘code’: 69, ‘message’: ‘Driver unavailable: Driver path: ‘, ‘driver_path’: ”, ‘browser_path’: ”} The above exception was the direct cause of the following exception: NoSuchDriverException Traceback (most recent call last) Cell In[13], line 1 —-> 1 webdriver.Chrome() File ~anaconda3libsite-packagesseleniumwebdriverchromewebdriver.py:45, in WebDriver.__init__(self, options, service, keep_alive) 42 service = service if service else Service() 43 options = options if options else Options() —> 45 super().__init__( 46 DesiredCapabilities.CHROME[“browserName”], 47 “goog”, 48 options, 49 service, 50 keep_alive, 51 ) File ~anaconda3libsite-packagesseleniumwebdriverchromiumwebdriver.py:51, in ChromiumDriver.__init__(self, browser_name, vendor_prefix, options, service, keep_alive) 47 self.vendor_prefix = vendor_prefix 49 self.service = service —> 51 self.service.path = DriverFinder.get_path(self.service, options) 53 self.service.start() 55 try: File ~anaconda3libsite-packagesseleniumwebdrivercommondriver_finder.py:41, in DriverFinder.get_path(service, options) 39 except Exception as err: 40 msg = f”Unable to obtain driver for {options.capabilities[‘browserName’]} using Selenium Manager.” —> 41 raise NoSuchDriverException(msg) from err 43 if path is None or not Path(path).is_file(): 44 raise NoSuchDriverException(f”Unable to locate or obtain driver for {options.capabilities[‘browserName’]}”) NoSuchDriverException: Message: Unable to obtain driver for chrome using Selenium Manager.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

このエラーは、ChromeのバージョンとChrome WebDriverのバージョンが互換性のないことに起因しています。Chrome WebDriverのバージョンがChromeのバージョンと一致していない場合、このようなエラーが発生します。

解決するためには、次の手順を実行してください:

  1. インストールされているChromeのバージョンを確認します。
  2. そのバージョンに対応したChrome WebDriverをダウンロードします。
  3. ダウンロードしたChrome WebDriverのパスをPythonスクリプトで指定します。

以下は、手順の一例です:

python
from selenium import webdriver # Torプロキシを経由してリクエストを送信するための設定 tor_proxy = "socks5://127.0.0.1:9150" tor_options = webdriver.ChromeOptions() tor_options.add_argument('--proxy-server=%s' % tor_proxy) # Chrome WebDriverのパスを設定 chrome_driver_path = 'Chrome WebDriverのパスを指定' # ダウンロードしたWebDriverのパスを指定してください # Chrome WebDriverを起動 browser = webdriver.Chrome(executable_path=chrome_driver_path, options=tor_options) # ウェブサイトにアクセス browser.get("https://example.com") # ページのタイトルを表示 print(browser.title) # ブラウザを終了 browser.quit()

Chrome WebDriverのバージョンがChromeのバージョンと一致していることを確認してください。これにより、エラーが解消されるはずです。

未分類

Posted by ぼっち