简体   繁体   中英

How to send batch requests to Google pagespeed API?

I've just started testing the Google Pagespeed API and can't find a clear answer as to how to do batch requests. I have a variable in Javascript containing urls that I'd like to test page speed for. I was wondering how I'd go about making a batch request using it? This is the code I have so far for making requests

    fetch(' https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://www.zizzi.co.uk/&key=MYKEY')
        .then(res => {
            return res.json();
            console.log(res.json)

'MYKEY' is replaced with my actual API in the code I am running.

you can't send batch requests to the API.

You also have a limit on how many requests you can make per minute and per day (I think it is quite high, around 25,000 / day).

Instead make multiple requests to the API alongside each other.

You may also consider installing Lighthouse , the engine that powers Page Speed Insights on your own server so you can easily save the JSON to files (as a browser will start to struggle with so many large responses).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM