我正在尝试自动获取许多不同页面的分数。但是api似乎不像网络版本那样提供整体评分。
我尝试使用Lighthouse API v5和v4,似乎都没有得分,我可能会错过它。我通过在pagespeed见解网站上使用puppeteer使其正常工作,但是此后已停止工作,并希望在尝试再次修复之前,我没有错过任何东西
您的设置肯定有问题。尝试通过铬运行它,对我来说以下工作正常:
安装铬和灯塔:
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
返回的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":
......