vinipis / google-pagespeed-api

Automating PageSpeed Tests with Python & Google PageSpeed Insights API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Observabilidade - Light House

Projetc Samsung with Elasticsearch

Note

This program sends a JSON with pageSpeed information (URL performance) of various URLs to Elasticsearch. You need knowledge about Elasticsearch and Index to get the most out of them. We assume that you already know how requests work. For it to work, you'll need to make a few small tweaks to your business.

Create .env

  1. Create a key at https://developers.google.com/speed/docs/insights/v5/get-started to get access to pagespeed.
  2. Create an .env file in the root directory.
  3. In the variable PAGE_SPEED_URL_API you must put the following link: https://www.googleapis.com/pagespeedonline/v5/runPagespeed
  4. In the CAPTCHA_TOKEN variable you must add the token you received from the PageSpeed API.
  5. ELASTIC_URL_API must be a submission URL for Elasticsearch.
  6. AUTH_USER and AUTH_PASS must be created within Elasticsearch with admin or superadmin permission.

How JSON is Constructed

We have a file called pagespeed.json that gathers part of what we are going to send to Elasticsearch, we also get the 6 metrics that make up Light House plus the page score, which are:

  1. first-contentful-paint
  2. interactive
  3. speed-index
  4. total-blocking-time
  5. largest-contentful-paint
  6. cumulative-layout-shift
  7. Socre (Plus)

Note

There are other metrics on pageSpeed, but we are limiting the 6 main metrics, to learn more visit the link https://developers.google.com/speed/docs/insights/v5/about

In the pagespeed.json file we must create it according to the following pattern:

[{"url":"https://www.google.com.br/"},{"url":"https://www.google2.com.br/"}]

or

[{"url":"https://www.google.com.br/", "menu": "menu name"}, {"url":"https://www.google2.com.br/ ", "menu": "menu name"}]

for URLs that have categories or subcategories or that are inside menus.

Note

The URL parameter is mandatory for the program to work correctly.

About

Automating PageSpeed Tests with Python & Google PageSpeed Insights API


Languages

Language:Python 100.0%