gpt4 book ai didi

python-3.x - Chrome Canary headless 模式在 Windows 10 上不起作用

转载 作者:行者123 更新时间:2023-12-04 17:47:48 25 4
gpt4 key购买 nike

Google Chrome Canary 不适用于 Windows 上的 headless。

Chrome headless 不适用于 Windows。当我尝试执行以下代码时,错误发生如下。但它适用于非 headless 模式。

我知道 Canary 不稳定,但我想用它来学习 Web 高级规范。

这个错误是由金丝雀中的错误引起的?还是我的代码引起的?

代码:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

op = Options()
op.binary_location = "C:\\Users\\username\\AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe"
op.add_argument("--headless")
op.add_argument("--disable-gpu")

driver = webdriver.Chrome("chromedriver.exe", chrome_options=op)

driver.get("http://www.google.com")

错误:

[1205/232511.644:ERROR:gpu_process_transport_factory.cc(1017)] Lost UI shared context.
[1205/232511.644:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232511.644:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics

DevTools listening on ws://127.0.0.1:12022/devtools/browser/3d7c8ff8-625a-4326-b968-bbff
[1205/232511.714:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232511.714:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
[1205/232511.714:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232511.714:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics
[1205/232513.037:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232513.037:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics

操作系统:windows 10 Home 1709
Chrome: 65.0.3285.0 (Official Build) canary 64bit
Chrome 驱动程序:2.33.506120

最佳答案

由于您的错误日志报告如下:

[1205/232511.644:ERROR:gpu_process_transport_factory.cc(1017)] Lost UI shared context.
[1205/232511.644:ERROR:instance.cc(49)] Unable to locate service manifest for metrics
[1205/232511.644:ERROR:service_manager.cc(890)] Failed to resolve service name: metrics

我会建议以下步骤:

  • 通过 Revo Uninstaller
  • 从系统中卸载 Google Chrome Canary
  • 使用 CCleaner 工具清除所有操作系统杂项。
  • 安装全新的 Google Chrome Canary
  • 使用以下代码块:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options

    op = Options()
    op.binary_location = "C:\\Users\\username\\AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe"
    op.add_argument("--headless")
    op.add_argument("--disable-gpu")
    driver = webdriver.Chrome(chrome_options=op, executable_path=r'C:\path\to\chromedriver.exe')
    driver.get("http://google.com/")

You can find about multiple ways to work with multiple Chrome Browser Binaries in Set chrome browser binary to chrome webdriver in Python discussion.

关于python-3.x - Chrome Canary headless 模式在 Windows 10 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47656059/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com