源码: 1、导入seleniumfrom selenium import webdriver 2、创建浏览器操作对象path = 'chromedriver.exe' browser = webdriver.Chrome(path) 3、访问网站- url = 'https://www.jd.com/'
- browser.get(url)
- 错误:
- F:\pycharm_stu\crawler_learning\078_爬虫_selenium_基本使用.py:9: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
- browser = webdriver.Chrome(path)
- Traceback (most recent call last):
- File "D:\Python310\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
- self.process = subprocess.Popen(cmd, env=self.env,
- File "D:\Python310\lib\subprocess.py", line 966, ininit
- self._execute_child(args, executable, preexec_fn, close_fds,
- File "D:\Python310\lib\subprocess.py", line 1435, in _execute_child
- hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
- FileNotFoundError: [WinError 2] 系统找不到指定的文件。
- During handling of the above exception, another exception occurred:
- Traceback (most recent call last):
- File "F:\pycharm_stu\crawler_learning\078_爬虫_selenium_基本使用.py", line 9, in
- browser = webdriver.Chrome(path)
- File "D:\Python310\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, ininit
- super(WebDriver, self).init(DesiredCapabilities.CHROME['browserName'], "goog",
- File "D:\Python310\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 90, ininit
- self.service.start()
- File "D:\Python310\lib\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://chromedriver.chromium.org/home
- Process finished with exit code 1
复制代码
|