Skip to content

Instantly share code, notes, and snippets.

@jhollist
Last active January 26, 2017 18:12
Show Gist options
  • Save jhollist/1ff1c5479fa5962e49a5d782a94b4a20 to your computer and use it in GitHub Desktop.
Save jhollist/1ff1c5479fa5962e49a5d782a94b4a20 to your computer and use it in GitHub Desktop.
R script to scrape US EPA NARS data and metadata
#Script to scrape NARS website
library(rvest)
library(dplyr)
nars <- read_html("https://www.epa.gov/national-aquatic-resource-surveys/data-national-aquatic-resource-surveys")
links <- nars %>%
html_nodes(".file-link, a") %>%
html_attr("href") %>%
tbl_df() %>%
filter(grepl("files",value)) %>%
mutate(url = paste0("https://www.epa.gov",value))
for(i in seq_along(links$url)){
httr::GET(links$url[i],httr::write_disk(basename(links$value[i]),overwrite=T))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment