Google PageSpeed API with Python

Поділитися
Вставка
  • Опубліковано 2 лют 2025

КОМЕНТАРІ • 12

  • @benita1040
    @benita1040 2 роки тому +1

    how i set a bandwidth for differnent webpages using python..

    • @rohbot
      @rohbot  2 роки тому

      Hey Benita,
      that is a great question. In a nutshell the pagespeed API does not offer throtteling, since the pagespeed run is actually done on a google machine and not with your own internet connection/browser. As of now, there is no parameter to configure this with the API.
      For your use case it would be best to use the Lighthouse command line interface (CLI) from Google: github.com/GoogleChrome/lighthouse. You can very easily install this with node.js (no javascript knowledge is involved for this to work, promised :-) )
      -> I also wrote down the steps to follow in one of the comments about testing a private page.
      The lighthouse CLI documentation has a dedicated section about throttling/bandwidth. Having a different bandwidth setting can be achieved by using another command line tool called sitespeed.io/throttle (www.npmjs.com/package/@sitespeed.io/throttle) which also can be installed via node.js.
      The section for further details on how to vary your bandwidth can be found here: github.com/GoogleChrome/lighthouse/blob/main/docs/throttling.md
      Might be not the most convenient solution, but it is a solvable problem :-)
      Let me know if this helps!
      Stay Great
      Martin

  • @javiervelasquezgil4109
    @javiervelasquezgil4109 2 роки тому +1

    Hi thanks for the video, how can I test a private site with login hosted in my private Lan?

    • @rohbot
      @rohbot  2 роки тому

      Hey @Javier,
      great question. You could technically test all pages in a chrome browser by just opening the google chrome developer tools (ctrl+shift+j on a windows machine while being in google chrome) and then go the tab called "Lighthouse" :-)
      It is not entirely the same as the API, but at least you can analyze your page.
      Let me know if this was helpful or if I missunderstood your question
      Stay Great
      Martin

    • @javiervelasquezgil4109
      @javiervelasquezgil4109 2 роки тому +2

      @@rohbot thanks for your answer, yes I'm actually using the performance insights option in the inspect menu but I thought tweaking the API I could do it.

    • @rohbot
      @rohbot  2 роки тому +1

      Ah understood, to automate this for internal network you could also use the lighthouse CLI from google github.com/GoogleChrome/lighthouse
      it uses puppeteer in the background and executes locally. Also has a headless option to run this somewhere within your internal network remotely
      with node installed:
      npm install -g lighthouse
      once installed you can do f.ex.
      lighthouse www.google.com
      or if you application runs on port 8080 locally and you would like to store the results as a json file
      lighthouse localhost:8080 --output json --output-path my_internal_page.json
      also adding headless mode:
      lighthouse localhost:8080 --output json --output-path lighthouse_internal_page.json --chrome-flags="--headless"
      let me know if that solves it :-)
      Also to add this: With the Pagespeed API the request is always from the Google Bot, not from your own IP. That is an advantage in case you would like to see how your competitors rank without being noticed and disadvantage if you have not publicly accessible or indexable pages :-)

  • @olegzhukov1204
    @olegzhukov1204 11 місяців тому

    Thank you so much!

  • @kostiantyny
    @kostiantyny Рік тому +1

    thanks a lot!

  • @hubertcombomarketing2693
    @hubertcombomarketing2693 26 днів тому

    This was very helpful information, but please do not add background music. It makes you harder to hear and the music is not to my taste. Thank you.

  • @yoyo211096
    @yoyo211096 2 роки тому

    Hi, is there a way to stock this in a database so I can make daily graph about the seo score etc?

    • @rohbot
      @rohbot  2 роки тому +1

      Hey, yes that is absolutely possible :-) - The video is only showing how to receive the data, you could store the results f.ex. it into a pandas DataFrame. From there on you could save it as a csv, or load it into various databases. Pandas is a quite nice library for inserting smaller pieces of data into different systems.
      you could use:
      - pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_sql.html to generate SQL inserts
      or
      - pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_csv.html to store your data as a csv
      There are also plenty of very good resources on how to ingest data into a database here on UA-cam :-)

    • @yoyo211096
      @yoyo211096 2 роки тому

      @@rohbot Thank you verymuch!