Selenium を使ってChromeでスクレイピング処理をしたいのですが、driverの取得ができません。
インストールされているGoogleChromeのバージョンは97.0.4692.71で、そのバージョンにあったchromedriverをこちらからダウンロードしています。
https://sites.google.com/chromium.org/driver/
ダウンロードしたファイルは以下のPATHにおいているのですが、
/Users/XXX/Documents/Python/chromedriver
Python
1from selenium import webdriver 2driver = webdriver.Chrome(executable_path='/Users/XXX/Documents/Python/chromedriver')
こちらを実行すると以下のエラーが出ます。
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 72, in start self.process = subprocess.Popen(cmd, env=self.env, File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/Users/XXX/Documents/Python/chromedriver.exe' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/XXX/Documents/Python/test.py", line 25, in <module> driver = webdriver.Chrome(executable_path='/Users/XXX/Documents/Python/chromedriver.exe') File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__ self.service.start() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 81, in start raise WebDriverException( selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Terminalでカレントディレクトリにおいて以下を実行すると
python --version
Python 2.7.16
とでますが、実行がPython3.9のようで、PATHあたりが問題なのですがどうすればよいか分からずお知恵をお貸し頂けないでしょうか?
