以自动方式获得灯塔的总体评分

问题描述 投票:0回答:2

我正在尝试自动获取许多不同页面的分数。但是api似乎不像网络版本那样提供整体评分。

我尝试使用Lighthouse API v5和v4,似乎都没有得分,我可能会错过它。我通过在pagespeed见解网站上使用puppeteer使其正常工作,但是此后已停止工作,并希望在尝试再次修复之前,我没有错过任何东西

pagespeed google-pagespeed lighthouse pagespeed-insights
2个回答
0
投票

您的设置肯定有问题。尝试通过铬运行它,对我来说以下工作正常:

安装铬和灯塔:

sudo install --y chromium-browser
sudo npm install -g lighthouse
lighthouse --output-path=./Production-lighthouse-report.html URL

通过无头镶边在所需URL上运行Lighthouse Tests的脚本:

lighthouse --chrome-flags="--headless" --output-path=./Production-lighthouse-report.html URL

0
投票

返回的JSON在lighthouseResult下有一个称为categories的部分。

categories内,您会看到performance,然后score是一个孩子,那里的分数超过1(所以89的分数是0.89)。

"lighthouseResult": {
......
    "categories": {
        "performance": {
            "id": "performance",
            "title": "Performance",
            "score": 1.00, <- here is the score.
            "auditRefs":
......
© www.soinside.com 2019 - 2024. All rights reserved.