从命令行运行Chrome灯塔的审核 [英] Run chrome lighthouse's audit from command line

查看:178
本文介绍了从命令行运行Chrome灯塔的审核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个脚本,该脚本运行(从chrome的二进制文件)其lighthouse的审核,并提供给定的url. 我没有设法找到方法,但是由于甚至还有一个chrome扩展程序,我都认为它应该是可行的吧?

I would like to write a script which run (from the chrome's binary) its lighthouse's audit with a url given. I didn't manage to find how to do it, but since there is even a chrome extension doing I assume it should be feasible right ?

推荐答案

可以使用命令行运行Google Lighthouse.要从命令行运行它,必须首先安装:

Google Lighthouse can be ran using the command line. To run it from the command line, you must first install:

  • Google Chrome for Desktop
  • Node.js v6 or later.

要安装Lighthouse CLI,请打开命令行并键入以下命令:

To install the Lighthouse CLI, open a command line and type the following command:

npm install -g lighthouse

要使用Lighthouse进行审核,请输入:

To run an audit with Lighthouse, type:

lighthouse https://example.com

默认情况下,Lighthouse将报告写入HTML文件.您可以通过传递标志来控制输出格式.

By default, Lighthouse writes the report to an HTML file. You can control the output format by passing flags.

您会注意到,每次运行Lighthouse时都会打开一个Chrome窗口.如果您不希望打开窗口,则可以在无头模式下运行它:

You will notice that a Chrome window is opened every time you run Lighthouse. If you don't want a window to be opened, you can run it in headless mode:

lighthouse https://example.com/ --chrome-flags="--headless"

有关选项的完整列表,请输入:

For the complete list of options, type:

lighthouse --help

请参阅灯塔源代码存储库,以获取其他文档和示例.

Take a look at the Lighthouse source code repository for additional documentation and examples.

这篇关于从命令行运行Chrome灯塔的审核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆