This site gets the data from a GraphQL API call :
POST https://comptox.epa.gov/dashboard/graphql
And when you click the download button it sends the same data to another api to format the data and download the tsv.
You can get the data from the API and format it into a tsv file in the first place :
library(httr)
query <- "{
lists {
label
abbreviation
short_description
chemical_count
updated_at
}
}"
r <- POST("https://comptox.epa.gov/dashboard/graphql",
content_type("application/json"),
body = list(
query = query
), encode = "json")
data <- content(r, "parsed")
#add link column
for(i in seq_along(data$data$lists)){
data$data$lists[[i]]$acronym <- paste("https://comptox.epa.gov/dashboard/chemical_lists", data$data$lists[[i]]$abbreviation, sep="/")
}
#convert to dataframe
df <- do.call(rbind.data.frame, data$data$lists)
write.table(df, file = "chemical.tsv", row.names=FALSE, sep="\t", quote = FALSE)
Output of file :
