2

我是初学者级别的python程序员,

我目前正在使用 selenium 开发浏览器自动化程序,但目前我正在使用勇敢的版本 96.0.4664.45 并且我的 chrome 驱动程序无法正常工作,而 geckodriver 与 firfox 一起工作正常

这里的错误---> python 路径中的 selenium 库错误,在我这边都是正确的

请尽快帮助我

4

2 回答 2

0

我建议尝试 webdriver_manager

https://github.com/SergeyPirogov/webdriver_manager

它有助于设置 chromedriver 的路径。

对于铬:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())

对于铬:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType

driver = webdriver.Chrome(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install())

我想其中一些对勇敢者有用。

另外,看看这个例子:

https://gist.github.com/passivebot/91d726bafc1f08eb475dd8384a3f21db

于 2021-12-24T14:14:34.473 回答
0

要启动的浏览上下文,您需要:

  • 使用binary_location属性指向勇敢的二进制位置。
  • 使用chromedriver可执行文件启动勇敢的浏览器。

代码块:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

option = webdriver.ChromeOptions()
option.binary_location = r'C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe'
driverService = Service('C:/Users/.../chromedriver.exe')
driver = webdriver.Chrome(service=driverService, options=option)
driver.get("https://www.google.com")

参考

您可以在以下位置找到一些相关的详细讨论:

于 2021-12-24T19:10:46.630 回答