Both curl
and wget
offer the ability to download a sequential range of files ([1-100]
in curl
, {1..100}
in wget
) but each of them have a shortcoming: curl
offers no easy way to pause between each download in the sequence. Some servers cut off downloads after several rapid downloads, and, in any case, it is polite and proper to pause between downloads anyways to be a good scraper citizen. If one wanted to, say, pause 5 seconds between each request, my understanding is there is no way to do this without additional scripting that essentially defeats the point of having the built-in support for a sequential range by making individual requests.
A solution to this is to use wget
which has the handy --wait=5
flag to achieve the above desired result. Unfortunately, wget
has other problems. It seems to struggle with special characters in URLs, and quotes around the URL can't be used because the range {1..100}
then appears to go unrecognized. This means some manual escaping of special characters is sometimes needed. This is manageable, but annoying.
However, more importantly, wget
has no support for naming the output dynamically (the -O
flag is of no help here). Though curl
offers the convenient -o "#1.jpg"
there appears to be no way to achieve the same dynamic result in wget
without, again, bypassing built-in sequential range support and making a scripted collection of single requests, or else having to rename
or otherwise edit the file names after download.
This strikes me as a fairly common task: downloading a sequential range of source files, politely pausing between each request, and renaming the output dynamically. Am I missing some alternative to curl
and wget
that overcomes the two problems above: 1) pause between each request 2) output file names dynamically.
aria2
might be your friend :-)