Description Usage Arguments Details Value Examples
View source: R/download_pagespeed.R
Download single or multiple URLs in variety of options.
1 2 3 4 5 | download_pagespeed(url, key = Sys.getenv("PAGESPEED_API_KEY"),
output_type = "simple", strategy = "desktop", interval = 0.5,
filter_third_party = NULL, locale = NULL, rule = NULL,
screenshot = NULL, snapshots = NULL, utm_campaign = NULL,
utm_source = NULL)
|
url |
vector of character strings. The URLs to fetch and analyze. MUST contain "http://" or "https://". |
key |
string. Pagespeed API key to authenticate. Defaults to "PAGESPEED_API_KEY" enviroment variable. |
output_type |
string. Choose how to parse the output. Options: "simple" or "raw". See more in Details section |
strategy |
string/character vector. The analysis strategy to use.
Options: |
interval |
numeric. Number of seconds to wait between multiple queries. Defaults to 0.5 second. |
filter_third_party |
logical. Indicates if third party resources should be filtered out before PageSpeed analysis. Defaults to NULL (= FALSE) |
locale |
string. The locale used to localize formatted results |
rule |
string. A PageSpeed rule to run; if none are given, all rules are run |
screenshot |
logical. Indicates if binary data containing a screenshot should be included. Defaults to NULL (= FALSE) |
snapshots |
logical. Indicates if binary data containing snapshot images should be included. Defaults to NULL (= FALSE) |
utm_campaign |
string. Campaign name for analytics. Defaults to NULL |
utm_source |
string. Campaign source for analytics. Defaults to NULL |
The output_type
parameter regulates how the output will be
parsed and stored.
For "simple" - formatted data frame that contains most of the data
(scores, recommendations and error occurences).
For "raw" - unformatted nested list that contains all the data that
was returned by the API.
The api_version
parameter regulates which API version is to
create the report. Legacy version 4 is now default, but it will
change in the future as version 5 supports additional Lighthouse
reports.
The categories
parameter works only for API version 5.
It regulates which of the tests' categories from Lighthouse
are to be run. You can select more than one in a vector.
Options: "accessibility", "best-practices", "performance", "pwa",
"seo".
two options: data frame (if "simple"), nested list (if "raw")
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | ## Not run:
# download simple data frame with Pagespeed report for Google.com
ps_df_1 <- download_pagespeed(url = "https://www.google.com", output_type = "simple")
# run Pagespeed reports for Google.com & Bing.com for mobile and
# return in a data frame with most important columns
ps_df_2 <- download_pagespeed(url = c("https://www.google.com",
"https://www.bing.com/"),
output_type = "simple", # return the results in a wide data frame
strategy = "mobile", # run tests for mobile
interval = 1) # wait 1 second between the calls to API
# run Pagespeed reports for Google.com & Bing.com for both desktop & mobile and
# return in a data frame with most important columns
ps_df_3 <- download_pagespeed(url = c("https://www.google.com",
"https://www.bing.com/"),
output_type = "simple", # return the results in a wide data frame
strategy = c("desktop", # check both desktop and mobile, bind
"mobile"),
interval = 2) # wait 2 seconds between the calls to API
# download nested list with Pagespeed report for Google.com
ps_nl_1 <- download_pagespeed(url = "https://www.google.com",
output_type = "raw")
# run Pagespeed for Google.com & Bing.com for desktop and
# return in a nested list with all possible data
ps_nl_2 <- download_pagespeed(url = c("https://www.google.com",
"https://www.bing.com/"),
output_type = "raw",
strategy = "desktop",
interval = 1)
# check "Performance" for Google.com & Bing.com for both desktop & mobile and
# return in a nested list with all possible data
ps_nl_3 <- download_pagespeed(url = c("https://www.google.com",
"https://www.bing.com/"),
output_type = "raw",
strategy = c("desktop",
"mobile"),
interval = 2)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.