【问题标题】:How to initiate selenium web driver with brave browser using python如何使用 python 使用勇敢的浏览器启动 selenium web 驱动程序
【发布时间】:2021-01-02 01:35:45
【问题描述】:

我的铬版本是 87.0.4280.88

我的勇敢浏览器版本是87.0.4280.101

我尝试了很多代码,但都不起作用。

代码:

from selenium import webdriver

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

错误回溯:

Traceback (most recent call last):
File "c:\Users\MOHSEN\Desktop\test\Untitled-1.py", line 5, in <module>
driver = webdriver.Chrome(
TypeError: __init__() got an unexpected keyword argument 'options'

【问题讨论】:

  • 您需要提供更多细节。
  • 您需要添加:Python 版本、您尝试执行的代码、selenium 驱动程序版本以及您遇到的错误。
  • this列表中,来自selenium的官网。此处未列出 Brave。
  • 能把错误和代码放在这里吗?
  • 请阅读How to Ask,尤其是关于minimal reproducible example(MCVE)和How much research effort is expected?的部分,这将帮助您调试自己的程序并自己解决问题。如果您这样做并且仍然卡住,您可以返回并发布您的 MCVE、您尝试过的内容以及执行结果(包括任何错误消息),以便我们更好地帮助您。还提供指向页面和/或相关 HTML 的链接。

标签: python selenium brave-browser


【解决方案1】:

要使用Selenium 驱动的WebDriver 启动 浏览会话,您可以使用以下解决方案:

  • 代码块:

    from selenium import webdriver
    
    option = webdriver.ChromeOptions()
    option.binary_location = r'C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe'
    driver = webdriver.Chrome(executable_path=r'C:\WebDrivers\chromedriver.exe', options=option)
    driver.get("https://www.google.com")
    
  • 浏览器快照:

【讨论】:

  • 我试过了,得到了这条消息 Traceback(最近一次调用最后一次):文件“c:\Users\MOHSEN\Desktop\test\Untitled-1.py”,第 5 行,在 driver = webdriver.Chrome( TypeError: __init__() got an unexpected keyword argument 'options'
猜你喜欢
  • 2022-06-26
  • 2018-04-02
  • 2019-02-22
  • 1970-01-01
  • 1970-01-01
  • 2015-01-15
  • 1970-01-01
  • 2015-06-08
  • 2016-05-20
相关资源
最近更新 更多