Yoh*_* AI 8 google-chrome headless-browser google-chrome-headless
我已经从developers.google中了解到有关Chrome Headless的信息,我们可以在没有用户界面的情况下运行Google.从该链接引用:
无头Chrome在Chrome 59中发布.这是在无头环境中运行Chrome浏览器的一种方式.基本上,运行没有铬的Chrome!它将Chromium和Blink渲染引擎提供的所有现代Web平台功能引入命令行.
为什么这有用?
无头浏览器是自动测试和服务器环境的绝佳工具,您不需要可见的UI shell.例如,您可能希望针对真实网页运行某些测试,创建PDF,或者仅检查浏览器如何呈现URL.
这是非常好的功能,所以我做了一些很酷的功能实验.想法是通过从Windows命令提示符调用chrome.exe来将快照作为文档站点,如下所示:
chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/
Run Code Online (Sandbox Code Playgroud)
做了几次并遵循这些网站的指示.我一无所获.我没有得到任何带有名称的图片或截图,screenshot.png因为之前提到过它Running with --screenshot will produce a file named screenshot.png in the current working directory.
从这份文件中也谈到版本,
警告:Chrome 59中的Mac和Linux上提供无头模式.Chrome 60中将提供Windows支持.要查看您的Chrome版本,请打开chrome:// version.
在使用之前的建议进行一些检查后,我chrome://version在Windows x64计算机上的Chrome上运行并获得了一些结果:
Google Chrome 62.0.3202.94 (Official Build) (64-bit) (cohort: Stable)
Revision 4fd852a98d66564c88736c017b0a0b0478e885ad-refs/branch-heads/3202@{#789}
Run Code Online (Sandbox Code Playgroud)
怎么了?我错过了什么?谢谢
Yoh*_* AI 10
做了一些实验.for --screenshot将保存图像与chrome.exe位置相同的级别,这将意味着保存Program Files.
所以我们需要将参数名和参数与a组合起来
--screenshot ="D:\ screen.png"将起作用,否则Chrome会写入其安装文件夹.大的设计缺陷,没有软件应该使用它的安装文件夹作为工作目录.
以下是完整的论点:
chrome --headless --enable-logging --disable-gpu --screenshot="D:\screen.png" "https://www.chromestatus.com/"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3066 次 |
| 最近记录: |