Coco697
Coco697

Reputation: 11

Lighthouse API: how to retrieve "diagnostics" part in CSV or JSON format? I can only do it in HTML format

On a website I would like to get both metrics value (like Core Web Vitals (LCP, FID, CLS)) and diagnostics (solutions to bad metrics value) when the metrics value is bad. Lighthouse (Chrome DevTools) can do it and there is Lighthouse API too.

Lighthouse API only gives metrics value for JSON and CSV reports, only HTML report gives metrics value and diagnostics. But I'm looking to get JSON and CSV reports with metrics value and diagnostics.

I followed the tutorial about using Lighthouse API https://medium.com/@giezendanenner/running-lighthouse-reports-on-the-command-line-1691a1b06a56

I can get reports with metrics value and diagnostics throught the command line:

"@For /F "UseBackQ Delims=" %%A In ("C:\Users\me\myProject\url.txt"
) Do @LightHouse "%%A" --chrome-flags="--headless" --output html"

Which means I'm doing a loop on my text file containing my list of urls "url.txt". The option "--output html" output, that gives me 5 html files report if my list contains 5 urls. Those files contain diagnostics which I'm very interested in.

However I would like to output the result in JSON or at least CSV format to further process them. I just need to change the option to "--output json" or "--output csv" but then there is no diagnostics, only metrics value in JSON or CSV reports. I found other libraries made by developers revolving around Lighthouse but the output is always metrics value which is good but I would like to have diagnostics too.

How would you approach the problem? I didn't really find an app to do it.

Thank you.

Upvotes: 1

Views: 290

Answers (0)

Related Questions