Skip to content

simitpatel/gpagespeed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Travis-CI Build Status

gpagespeed

gpagespeed is a package designed to facilitate utilization of the Google PageSpeed Insights API. The PageSpeed Insights API provides insight into how Google's bots evaluate a given page, and the factors that web developers may wish to consider in building pages that will render faster. See Google's documentation on the PageSpeed Insights API to learn more about what the API offers as well as practical examples of its usage.

The PageSpeed Insights API returns a numeric summary of the results of each page, as well as recommendations in text format. Currently, this package is designed to support only retrieving the numeric summary, which includes the overall speed score as well as metrics pertaining to the number of file requests and sizes in kilobytes of images, HTML, CSS, and JavaScript. The package offers two functions: speedfinder and speedlist. These functions are documented below.

Functions in gpagespeed

speedfinder
The speedfinder function returns a dataframe with a single observation and columns of numeric data as its response. It accepts three arguments:

  • url: The url argument refers to the URL of the document on which the PageSpeed Insights API should be run and the corresponding summary metrics returned.
  • strategy: This argument should have one of two potential text string inputs: "desktop" or "mobile" to denote the device context that the PageSpeed Insights API should use in its evaluation.
  • key: This is the key that is required to use the API. Visit Google's Developer Console to obtain your free key.

speedlist
The speedlist function is like the speedfinder function, but allows processing of many URLs and returns a dataframe in which each observation corresponds to a unique URL. Like speedfinder, it accepts three arguments:

  • pagelist: A list object in which each item in the list is a URL listed as a character string.
  • strategy: This argument should have one of two potential text string inputs: "desktop" or "mobile" to denote the device context that the PageSpeed Insights API should use in its evaluation.
  • key: This is the key that is required to use the API. Visit Google's Developer Console to obtain your free key.

Example Usage

Below are examples of how the speedfinder and speedlist functions could be called in an R script.

# Get speed metrics for a single URL and assign it to a data frame
df1 <- speedfinder("https://www.cars.com", "mobile", "atextkeyigotfromgoogle111")

# Get speed metrics for a list of URLs and have it all returned in a single data frame
df2 <- speedlist(c("https://www.cars.com", "http://www.yahoo.com", "http://www.techmeme.com"), 
            "mobile",
            "atextkeyigotfromgoogle111") 

About

An R package for the Google Page Speed Insights API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages