Parsing Google's Lighthouse Page speed json response to dataframe in R

139 Views Asked by At

I am having some difficulty parsing Google's pagespeed JSON response into a dataframe in R. Ideally I just want the dataframe to contain the speed metrics.

Code to get JSON response.

'''

library(httr)
library(jsonlite)
library(tidyverse)
library(rjson)

url <- "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://www.google.com"


raw_json <- url %>% 
  httr::GET() %>% 
  httr::content()


df_pagespeed <-  fromJSON(raw_json$lighthouseResult %>% str(max.level = 2))  

'''

I get the following error '''

json_str must be a character string

'''

0

There are 0 best solutions below