首页 > 解决方案 > 使用 PageSpeed Insights API v5 在终端中使用 curl 查找服务器响应时间

问题描述

使用 PageSpeed Insights API v5 在终端中使用 curl 查找服务器响应时间

例如,如果我在终端中输入这个

    curl \'https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://google.com/
&category=performance&strategy=mobile&fields=lighthouseResult.categories.*.score&prettyPrint=false
&key=<MY-KEY>'

将返回

{"lighthouseResult":{"categories":{"performance":{"score":0.68}}}}%

而不是分数,我希望它只返回类似于以下形式的服务器响应时间:

{"lighthouseResult":{"categories":{"performance":{"responseTime":0.68}}}}%

我尝试了以下方法:

  1. fields=lighthouseResult.categories.*.server-response-time
  2. fields=lighthouseResult.categories.*.server-response-time.responseTime
  3. fields=lighthouseResult.categories.audits.server-response-time
  4. fields=lighthouseResult.categories.audits.server-response-time.responseTime
  5. &only-audits=server-response-time

标签: terminallighthousegoogle-pagespeedgoogle-pagespeed-insights-api

解决方案


推荐阅读