如何获得 Lighthouse API 的有效响应

问题描述

我想得到 google lighthouse API 的结果,如果我在浏览器中输入它,它会起作用 https://developers.google.com/speed/pagespeed/insights/?hl=de

如果我使用带有 get-request 的 API,它会显示某些域的错误

通过这个请求,无论是在我的浏览器中还是在我的 python 代码中:

import requests


mobile_performance = requests.get('https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://de.wikipedia.org/wiki/Test%2F&fields=lighthouseResult%2Fcategories%2F*%2Fscore&prettyPrint=false&strategy=desktop&category=performance&category=pwa&category=best-practices&category=accessibility&category=SEO&key=**')
result_mobile = mobile_performance.json()
print(result_mobile)

我收到以下错误

{'error': {'code': 500,'message': 'Lighthouse returned error: ERRORED_DOCUMENT_REQUEST. Lighthouse was unable to reliably load the page you requested. Make sure you are testing the correct URL and that the server is properly responding to all requests. (Status code: 404)','errors': [{'message': 'Lighthouse returned error: ERRORED_DOCUMENT_REQUEST. Lighthouse was unable to reliably load the page you requested. Make sure you are testing the correct URL and that the server is properly responding to all requests. (Status code: 404)','domain': 'lighthouse','reason': 'lighthouseError'}]}}

有没有办法得到一个实际的结果,因为在谷歌的网站上它是有效的。 我想添加一些 headers,但我想它不会起作用,因为如果我在浏览器中输入它,它会抛出相同的错误

编辑:仍未解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)