Selenium与Brave浏览器的兼容问题
我最近一直在尝试用selenium进行网页抓取,结果在我的一台装有Chrome的设备上运行得很好。不过,如果可以的话,我想在我另一台装有Brave浏览器的设备上使用它。我试过这里提到的一些建议,但很遗憾,没有一个能成功,要么是因为selenium在更新,要么是我漏掉了什么重要的东西。
不过,这是我浏览器的规格:
1.63.169 Chromium: 122.0.6261.111(官方版本)(64位)
1 个回答
0
请确保你使用的是最新版本的selenium和兼容的chromedriver。下面的代码片段运行得很好,系统配置是 Ubuntu 22.04.4 LTS
和 1.63.169 Chromium: 122.0.6261.111 (官方版本) (64位)
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
# Specify the path to the Brave binary
# To find the executable path, type brave://version/ into the brave address bar and look for "Executable Path" field
brave_binary_path = '/snap/brave/371/opt/brave.com/brave/brave'
chrome_options.binary_location = brave_binary_path
# Initialize the ChromeDriver with the configured options
driver = webdriver.Chrome(options=chrome_options)
url = "https://www.test-site.com/"
driver.get(url)
driver.quit()