【问题标题】:How to get the mobile and desktop API path in page speed insights?如何在页面速度洞察中获取移动和桌面 API 路径?
【发布时间】:2022-06-17 03:31:37
【问题描述】:
您好,我只是想问一下在 pagespeed 洞察中性能得分是否有单独的 API?因为我只看到这条消耗性能分数的路径,我不知道它是用于桌面还是移动
lighthouseResult.categories.performance.score
【问题讨论】:
标签:
json
pagespeed
google-pagespeed
pagespeed-insights
google-pagespeed-insights-api
【解决方案1】:
根据结果确定策略,可以参考lighthouseResult.emulatedFormFactor
默认情况下,它为 DESKTOP 运行。
为了让它在 MOBILE 上运行,存在一个查询参数strategy
这里是 strategy=MOBILE 的示例请求
curl \
'https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?url=https%3A%2F%2Fexample.com&strategy=MOBILE&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
参考:here