51Testing软件测试论坛
标题: 想学习一下爬虫,安装好selenium后,打开谷歌失败,请问怎么解决呢。 [打印本页]
作者: 测试积点老人 时间: 2022-2-8 10:58
标题: 想学习一下爬虫,安装好selenium后,打开谷歌失败,请问怎么解决呢。
源码:
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
复制代码
作者: 海海豚 时间: 2022-2-9 09:31
webdriver位置放得对吗
作者: jingzizx 时间: 2022-2-9 17:53
配置的不对吧
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) |
Powered by Discuz! X3.2 |