————————————————————————— JSONDecodeError Traceback (most recent call last) File ~anaconda3libsite-packagesseleniumwebdrivercommonselenium_manager.py:129, in SeleniumManager.run(args) 128 stderr = completed_proc.stderr.decode(“utf-8”).rstrip(“n”) –> 129 output = json.loads(stdout) 130 result = output[“result”] File ~anaconda3libjson__init__.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 343 if (cls is None and object_hook is None and 344 parse_int is None and parse_float is None and 345 parse_constant is None and object_pairs_hook is None and not kw): –> 346 return _default_decoder.decode(s) 347 if cls is None: File ~anaconda3libjsondecoder.py:337, in JSONDecoder.decode(self, s, _w) 333 “””Return the Python representation of “s“ (a “str“ instance 334 containing a JSON document). 335 336 “”” –> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 338 end = _w(s, end).end() File ~anaconda3libjsondecoder.py:355, in JSONDecoder.raw_decode(self, s, idx) 354 except StopIteration as err: –> 355 raise JSONDecodeError(“Expecting value”, s, err.value) from None 356 return obj, end JSONDecodeError: Expecting value: line 1 column 1 (char 0) The above exception was the direct cause of the following exception: 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:132, in SeleniumManager.run(args) 131 except Exception as err: –> 132 raise WebDriverException(f”Unsuccessful command executed: {command}”) from err 134 for item in output[“logs”]: WebDriverException: Message: Unsuccessful command executed: C:Usersdell25anaconda3libsite-packagesseleniumwebdrivercommonwindowsselenium-manager.exe –browser chrome –output json The above exception was the direct cause of the following exception: NoSuchDriverException Traceback (most recent call last) Cell In[4], line 9 6 tor_options.add_argument(‘–proxy-server=%s’ % tor_proxy) 8 # Torブラウザの起動 —-> 9 browser = webdriver.Chrome(options=tor_options) 11 # ウェブサイトにアクセス 12 browser.get(“https://partsss.com/jp”) 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
このエラーは、SeleniumがChrome WebDriverのパスを見つけられないことが原因で発生しています。Chrome WebDriverのパスを正しく設定することで解決できます。
以下の手順で解決してみてください:
-
Chrome WebDriverのダウンロード: Chromeのバージョンに合わせたChrome WebDriverをダウンロードしてください。Chromeと同じバージョンのWebDriverを選択してください。
-
Chrome WebDriverのパスを設定: ダウンロードした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のパスを明示的に指定して、SeleniumがWebDriverを見つけられるようにします。これにより、このエラーが解消されるはずです。

ディスカッション
コメント一覧
まだ、コメントがありません