首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试使用selenium打开网页但得到错误

尝试使用selenium打开网页但得到错误
EN

Stack Overflow用户
提问于 2022-05-27 03:53:19
回答 1查看 1.1K关注 0票数 0

我写了这个简单的代码:

代码语言:javascript
复制
from selenium import webdriver
webdriver.Chrome().get('www.google.co.in')

但我发现了一个错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "C:\Users\user\PycharmProjects\WebAutomation\venv\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1435, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\user\PycharmProjects\WebAutomation\venv\Automation.py", line 2, in <module>
    webdriver.Chrome().get('www.google.co.in')
 File "C:\Users\user\PycharmProjects\WebAutomation\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
    super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "C:\Users\user\PycharmProjects\WebAutomation\venv\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 89, in __init__
    self.service.start()
  File "C:\Users\user\PycharmProjects\WebAutomation\venv\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home

谁来帮帮我。我是初学者,请详细解释/指导(我不知道复杂的概念)

EN

回答 1

Stack Overflow用户

发布于 2022-05-28 14:32:32

您将需要额外的Selenium-ChromeDriver.exe!最后一行错误告诉您。

selenium.common.exceptions.WebDriverException:消息:“

驱动程序”可执行文件需要在路径中。请参阅https://chromedriver.chromium.org/home

驱动程序本身将从您的程序启动,并将保存您的程序和浏览器铬本身之间的绑定。

driver.exe可以很容易地放置在程序启动路径中(我建议在第一步中这样做),也可以放置到任何您想要的位置,但是您必须定义driver.exe路径的特殊变量。

您可以在这个链接后面获得driver.exe:

主页:https://chromedriver.chromium.org/getting-started

下载网页:https://chromedriver.chromium.org/downloads

请确保您的浏览器版本与驱动程序版本匹配.

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72400294

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档