Reputation: 29
Wish to scrape weather data from
https://www.wetterzentrale.de/weatherdata.php?station=260&jaar=2019&maand=1&dag=1
From 2019-01-01 until today, yet I don't know how to write a code that changes jaar=2019 (i.e., year=2019), maand=1 (i.e., month=1) and dag=1 (i.e., day=1) to the desired days.
I tried to work with lapply as:
years <- c("2019", "2020")
urls <- rbindlist(lapply(years, function(x) {
url <- paste(https://www.wetterzentrale.de/weatherdata.php?station=260&jaar=2019&maand=1&dag=1, sep = "")
data.frame(url)
} ))
Hence this only gives the urls for 2019 and 2020. Is there a way to include months and days?
Upvotes: 1
Views: 29
Reputation: 8117
library(lubridate)
allYourDates <- seq(ymd(20190101), Sys.Date(), by = "days")
urls <- paste("https://www.wetterzentrale.de/weatherdata.php?station=260&jaar=", year(allYourDates)
, "&maand=", month(allYourDates)
, "&dag=", day(allYourDates)
, sep = "")
Upvotes: 1