admin管理员组文章数量:1567298
错误信息:Passthrough is not supported, GL is swiftshader
解决方案:通过ChromeOptions()
配置Selenium启动参数进而实现chromedriver
在Windows环境中以“无头模式”运行时于控制台的输出信息的控制:
from selenium.webdriver import Chrome, ChromeOptions
# True:chromedriver静默启动
SILENCE = True
def set_spider_option(chromedriver_path=None) -> Chrome:
# 调整chromedriver的读取路径,若不指定则尝试从环境变量中查找
chromedriver_path = "chromedriver" if chromedriver_path is None else chromedriver_path
# 实例化Chrome可选参数
options = ChromeOptions()
# 静默启动 参数组策略
if SILENCE is True:
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument("--disable-software-rasterizer")
# 其他推荐设置
options.add_argument('--log-level=3')
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option('excludeSwitches', ['enable-automation'])
return Chrome(options=options, executable_path=chromedriver_path)
def this_is_a_business(chromedriver_path):
api = set_spider_option(chromedriver_path)
try:
api.get("https://www.baidu")
input()
finally:
api.quit()
if __name__ == '__main__':
this_is_a_business(chromedriver_path=None)
参考资料
[1] [Solved] Python Selenium Chromedriver Error: (Passthrough is not supported, GL is disabled) | DebugAH
[2] python - Passthrough is not supported, GL is disabled - Stack Overflow
本文标签: supportedpassthroughswiftshaderGL
版权声明:本文标题:Passthrough is not supported, GL is swiftshader 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1725805357a1043962.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论