pip install selenium
在 jupiter 中安装 selenium 后,我下载了 chromedriver 并将其保存到 C:\Program Files\Google\Chrome\Application\chromedriver.exe
from selenium import webdriver
driver = webdriver.Chrome("C:\Program Files\Google\Chrome\Application\chromedriver.exe")
driver.get("https://instagram.com")
**我收到错误,例如请帮助使用 jupiter notebook 使用 chromedriver 任何帮助将不胜感激
即使我添加了根路径,r 字符串,也没有任何效果**
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
/srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/common/service.py in start(self)
75 stderr=self.log_file,
---> 76 stdin=PIPE)
77 except TypeError:
/srv/conda/envs/notebook/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
728 errread, errwrite,
--> 729 restore_signals, start_new_session)
730 except:
/srv/conda/envs/notebook/lib/python3.6/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1363 err_msg += ': ' + repr(err_filename)
-> 1364 raise child_exception_type(errno_num, err_msg, err_filename)
1365 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Program Files\\Google\\Chrome\\Application\\chromedriver.exe': 'C:\\Program Files\\Google\\Chrome\\Application\\chromedriver.exe'
During handling of the above exception, another exception occurred:
WebDriverException Traceback (most recent call last)
<ipython-input-8-924a85514f82> in <module>
1 from selenium import webdriver
----> 2 driver = webdriver.Chrome("C:\Program Files\Google\Chrome\Application\chromedriver.exe")
3 driver.get("https://instagram.com")
/srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
71 service_args=service_args,
72 log_path=service_log_path)
---> 73 self.service.start()
74
75 try:
/srv/conda/envs/notebook/lib/python3.6/site-packages/selenium/webdriver/common/service.py in start(self)
81 raise WebDriverException(
82 "'%s' executable needs to be in PATH. %s" % (
---> 83 os.path.basename(self.path), self.start_error_message)
84 )
85 elif err.errno == errno.EACCES:
WebDriverException: Message: 'C:\Program Files\Google\Chrome\Application\chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home