From aac828084366e48a25d5ec0d5ea67616f3e98346 Mon Sep 17 00:00:00 2001 From: flavis Date: Thu, 24 Jun 2021 13:30:30 +0200 Subject: [PATCH] beautify fetching --- scraping/fetch.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scraping/fetch.R b/scraping/fetch.R index 21a7954..c9b416e 100644 --- a/scraping/fetch.R +++ b/scraping/fetch.R @@ -16,9 +16,12 @@ download_protocol <- function(path, name) { } fetch_batch <- function(offset) { - url <- mk_url(offset) - res <- as.character(read_html(url)) - paths <- str_match_all(res, "/resource/blob/.*?/([0-9]*-data\\.xml)")[[1]] + mk_url(offset) %>% + read_html() %>% + as.character() %>% + str_match_all("/resource/blob/.*?/([0-9]*-data\\.xml)") %>% + `[[`(1) -> + paths mapply(download_protocol, paths[,1], paths[,2]) return(length(paths) > 0) }