空白的网页使用无头铬,该怎么办?
我的无头铬选项有问题。在屏幕截图中获取一个完全空白的页面。我在论坛上使用了一些建议,但没有任何效果。请参阅代码。
options = Options()
options.headless = True
options.add_argument("start-maximized")
options.add_argument("--window-size=1920,1080")
options.add_argument("--disable-gpu")
options.add_argument('--ignore-certificate-errors')
options.add_argument('--allow-running-insecure-content')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get_screenshot_as_file("screenshot.png")
I have a problem with the headless chrome option. Get a completely blank page in the screenshot. I've used a few suggestions here on the forum, but nothing works. See code.
options = Options()
options.headless = True
options.add_argument("start-maximized")
options.add_argument("--window-size=1920,1080")
options.add_argument("--disable-gpu")
options.add_argument('--ignore-certificate-errors')
options.add_argument('--allow-running-insecure-content')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get_screenshot_as_file("screenshot.png")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用此信息(其他选项)并设置窗口大小,然后您需要转到一些网页,否则将取空屏幕截图。
Try this for headless (other option) and set window size, then you need to go to some webpage or it will take a empty screenshot.