taylorbell.com

Using cURL to download sequential files

I was hitting a JSON endpoint that included the date as a query string. Using cURL provides a fast way to download the files to disk.

But it's annoying to only grab one at a time.

cURL supports ranges using like [01-10], and then getting the current number in the range for the filename with #1.

You can do multiple ranges like so:

curl https://coolsite.com/api?date=\[01-12\]-\[01-31\]-\[2017-2018\] -o "#1-#2-#3.json"

(Note that you'll have to escape those brackets).