how to scrape data from an interactive plot

I'm trying to scrape data from an interactive graph using r. So this is the url:

https://docs.google.com/spreadsheets/d/e/2PACX-1vQjDUQorXKZF9xsM6iR5Vl6oEc14uBj0g73arQdVAoQiWsppdFeaHpM0exftRlpCBGo591KVrFra_eF/pubchart?oid=1364851531&format=interactive

This is my code:

> library(jsonlite)
> library(httr)
> url <- "https://docs.google.com/spreadsheets/d/e/2PACX-1vQjDUQorXKZF9xsM6iR5Vl6oEc14uBj0g73arQdVAoQiWsppdFeaHpM0exftRlpCBGo591KVrFra_eF/pubchart?oid=1364851531&format=interactive"
> req <- GET(url)
> stop_for_status(req)
> json <- content(req, "text")
> mydata <- fromJSON(json)

And I got this error message:

Error: lexical error: invalid char in json text.
<meta name="referre
(right here) ------^

Is there another way to get the data from the interactive plot? Thank you in advance.

the content that you named 'json' is not json, therefore its an error to expect that fromJSON will parse it.
it appears to be HTML, I think its going to take more substantial effort to recover underlying data unfortunately.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.