如何在 Windows 上使用 Selenium 和 Python 启动 Brave 浏览器 [英] How to initiate Brave browser using Selenium and Python on Windows
本文介绍了如何在 Windows 上使用 Selenium 和 Python 启动 Brave 浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用:
- ChromeDriver 83.0.4103.39
- Brave 版本 1.10.97 Chromium:83.0.4103.116(官方版本)(64 位)
- Python 3.7
- Windows 10
代码试验:
from selenium import webdriverdriver_path = "C:/Users/username/PycharmProjects/chromedriver.exe";brave_path = "C:/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe";选项 = webdriver.ChromeOptions()option.binary_location =brave_path# option.add_argument("--incognito") 可选# option.add_argument("--headless") 可选# 创建新的 Chrome 实例浏览器 = webdriver.Chrome(executable_path=driver_path, chrome_options=option)browser.get("https://www.google.com")
我收到此错误
DevTools 监听 ws://127.0.0.1:54230/devtools/browser/406d1094-cd8c-48d5-930d-b7308f621429[8696:16300:0628/131830.277:ERROR:rewards_service_impl.cc(242)] 无法读取文件:C:\Users\Admin\AppData\Local\Temp\scoped_dir13924_173218860\Default\rewards_service\confirmations[9492:5280:0628/131830.304:ERROR:confirmations_impl.cc(774)] 无法加载确认状态,重置为默认值[8696:2268:0628/131830.405:ERROR:rewards_service_impl.cc(191)] 无法读取文件:C:\Users\Admin\AppData\Local\Temp\scoped_dir13924_173218860\Default\ledger_state[9492:5280:0628/131830.410:ERROR:ledger_impl.cc(122)] 无法初始化钱包
解决方案
打开一个
Using:
- ChromeDriver 83.0.4103.39
- Brave Version 1.10.97 Chromium: 83.0.4103.116 (Official Build) (64-bit)
- Python 3.7
- Windows 10
Code trials:
from selenium import webdriver
driver_path = "C:/Users/username/PycharmProjects/chromedriver.exe"
brave_path = "C:/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"
option = webdriver.ChromeOptions()
option.binary_location = brave_path
# option.add_argument("--incognito") OPTIONAL
# option.add_argument("--headless") OPTIONAL
# Create new Instance of Chrome
browser = webdriver.Chrome(executable_path=driver_path, chrome_options=option)
browser.get("https://www.google.com")
I'm getting this error
DevTools listening on ws://127.0.0.1:54230/devtools/browser/406d1094-cd8c-48d5-930d-b7308f621429
[8696:16300:0628/131830.277:ERROR:rewards_service_impl.cc(242)] Failed to read file: C:\Users\Admin\AppData\Local\Temp\scoped_dir13924_173218860\Default\rewards_service\confirmations.json
[9492:5280:0628/131830.304:ERROR:confirmations_impl.cc(774)] Failed to load confirmations state, resetting to default values
[8696:2268:0628/131830.405:ERROR:rewards_service_impl.cc(191)] Failed to read file: C:\Users\Admin\AppData\Local\Temp\scoped_dir13924_173218860\Default\ledger_state
[9492:5280:0628/131830.410:ERROR:ledger_impl.cc(122)] Failed to initialize wallet
解决方案
To open a brave Browsing Context using Selenium driven WebDriver you can use the following solution:
Code Block:
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")
Browser Snapshot:
这篇关于如何在 Windows 上使用 Selenium 和 Python 启动 Brave 浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文