You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Debian服务器上Seleniumbase运行Brave请求头缺失问题求助

如何用SeleniumBase在Debian服务器上正常运行Brave浏览器?

我需要在Debian服务器上结合undetected_chrome运行Brave浏览器,但遇到了一系列问题,具体尝试过程如下:

尝试1:使用undetected_chrome + binary_location配置

  • 问题:driver.quit()无法正常工作,而我需要每隔几分钟关闭并重新打开浏览器,因此转而尝试SeleniumBase。

尝试2:使用SeleniumBase + binary_location配置

  • 结果:SeleniumBase提示brave.exe不是有效的二进制文件。

尝试3:修改SeleniumBase的constants.py(Windows系统)

修改valid_chrome_binaries_on_windows列表,添加brave.exe:

valid_chrome_binaries_on_windows = [
    "chrome.exe",
    "chromium.exe",
    "brave.exe",
]

运行以下代码:

from seleniumbase import Driver

brave_path = r'C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe'
driver = Driver(uc=True, proxy=webdriver_proxy, incognito=True, page_load_strategy=load_strategy, block_images=True, binary_location=brave_path)
  • 结果:一切运行正常。

尝试4:修改SeleniumBase的constants.py(Debian服务器)

修改valid_chrome_binaries_on_linux列表,添加brave-browser和brave-browser-stable:

valid_chrome_binaries_on_linux = [
    "google-chrome",
    "google-chrome-stable",
    "chrome",
    "chromium",
    "chromium-browser",
    "google-chrome-beta",
    "google-chrome-dev",
    "google-chrome-unstable",
    "brave-browser",
    "brave-browser-stable",
]

运行以下代码:

brave_path = "/usr/bin/brave-browser"
driver = Driver(uc=True, proxy=webdriver_proxy, incognito=True, page_load_strategy=load_strategy, block_images=True, binary_location=brave_path)
  • 结果:浏览器可访问网页,但部分请求头缺失,触发网站机器人检测。

请求头对比

正常Brave请求头(undetected_chrome运行)

GET / HTTP/1.1
Host: whatismyheader.com
Connection: keep-alive
Sec-Ch-Ua: "Brave";v="119", "Chromium";v="119", "Not?A_Brand";v="24"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "Linux"
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8
Sec-Gpc: 1
Accept-Language: en-US,en;q=0.8
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate, br

测试请求头(修改后的SeleniumBase运行)

GET / HTTP/1.1
Host: whatismyheader.com
Connection: keep-alive
Sec-Ch-Ua:
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: ""
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.1.60.118 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8
Sec-Gpc: 1
Accept-Language: en-US,en;q=0.6
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate, br

求解决思路


内容的提问来源于stack exchange,提问作者Haski

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 02:55:56