How do I download the 240km radar scans between 2022-07-31 01:00:00 (am) and 2022-07-31 03:00:00 (am) at five-minute intervals, inclusive of end points?
I've noted the pattern in the image url: https://www.nea.gov.sg/docs/default-source/rain-area-240km/dpsri_240km_2022073101000000dBR.dpsri.png
where the string of numbers would represent the date and time. Currently, I have:
library(rvest)
library(httr)
interval <- seq(0, 55, by = 5)
hour <- c("01", "02", "03")
for (h in hour) {
for (i in interval) {
url <- paste("https://www.nea.gov.sg/docs/default-source/rain-area-240km/dpsri_240km_20220731", h, i, ".dpsri.png", sep = "")
imgurl <- read_html(url) %>%
html_node(css = "img") %>%
html_attr("src")
}
}
However, when I run this code, I get: Error in open.connection(x, "rb") : HTTP error 404.
Where did I go wrong? Also, how would I download the images and save them into a zip file?
Thank you.