Last active
January 26, 2017 18:12
-
-
Save jhollist/1ff1c5479fa5962e49a5d782a94b4a20 to your computer and use it in GitHub Desktop.
R script to scrape US EPA NARS data and metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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