Can I run Google page speed from the command line?

Can I run Google page speed from the command line? If so, how? I am interested in automating daily or daily Google PageSpeed ​​calls that will notify me after committing or daily if I have reduced the level of "Google PageSpeed" (for this page).

+6
source share
3 answers

On the command line, you can use PageSpeed ​​Insights :

Install via: $ npm install --global psi

Usage: $ psi <url> --key=<key> --prettyprint=<true> --userIp=<userIp> --locale=<locale> --strategy=<desktop|mobile>

Run it like this: $ psi http://stackoverflow.com

PageSpeed ​​Desktop Insights CLI

Also for mobile ideas: $ psi http://stackoverflow.com --strategy=mobile

PageSpeed ​​Mobile Insights CLI

UPDATE: you can use PageSpeed ​​Insights properties in your local development environment (Internet connection required) with grunt + grunt-pagespeed + ngrok . Checkout an example project for grunt-pagespeed and ngrok for more information.

Note. Run $ ngrok -authtoken <your-token> 80 and check the web interface settings to make sure you set the correct port in Gruntfile.js !

+8
source

There is a Google Page Speed ​​API . It will not work directly from the command line, but you can easily write a script in your chosen language that will interact with the API.

+3
source

You can use curl to run PageSpeed ​​from the command line as follows:

 curl "https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=http://your_url/&prettyprint=true&strategy=mobile&key=your_api_key" 

It will return human readable results to json. cmd-F "rating" to find the total score.

Link: Official Google api .

0
source

Source: https://habr.com/ru/post/911368/


All Articles