Python wrapper over Google Page Speed v5and optional integration over Google SpreadSheet to bulk common metrics information.
- First Contentful Paint
- Speed Index
- First Meaningful Paint
- First CPU Idle
- Max Potential First Input Delay
Use the package manager pip to install dependencies.
pip install -r requirements.txt.
from pagespeed import PageSpeedv5
page = PageSpeedv5(
os.getenv("API_KEY"), # pagespeed console api key
os.getenv("URL"), # https://example.com
os.getenv("STRATEGY") # desktop or mobile
)
# get light_house_result object
light_result = page.fetch_light_house()
# or get entire object
light_result = page.fetch_all()
from pagespeed import SpreadsheetReporter
SHEET_PAGE = 0
# AUTH_FILE json account service private key
# https://console.developers.google.com/apis/credentials
reporter = SpreadsheetReporter(os.getenv("AUTH_FILE"))
reporter.open(
os.getenv("SHEET_ID"),
SHEET_PAGE
)
# where light_result could be for instance
# light_result = page.fetch_light_house()
reporter.set_daily_metrics(light_result)
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.