I am calling API to download files using curl
package in R. Due to unknown reason, sometimes the connection breaks with error code: Error in curl_download(url = i, handle = h, df) : HTTP error 400.
Because I need to download about 100,000 files at a time and it's very slow, I wish R could retry once this error occurs instead of throwing me an error and stopping the script. Any thoughts?
my code is (simple version):
for (url in allUrl) {
df <- tempfile()
tryCatch(
curl_download(url = url,
handle = h,
df)
)
}