1

I would like to save my online textbook for offline usage, and through Google Chrome's "Network" panel I found out the path of the images. They can be accessed through the browser and downloaded using curl if given the correct configuration ("copy cURL"). The files look like the following: "https://c.m.com/r*/p*/R*/5*/5*/2*/O*/images/page.svgz", where is the page number with four digits, e.g. page0258.svgz. I would like to batch download them using some shell syntaxes. I use fish, but I can also use other shells.

How would I achieve that four number pattern expansion on the command line?

bmike
  • 235,889
Joy Jin
  • 2,733
  • Merging files is very different answer than how to glob / abstract a pattern of file names. See https://apple.stackexchange.com/questions/99210/mac-os-x-how-to-merge-pdf-files-in-a-directory-according-to-their-file-names? Or post a second question if you have an example of merging you can’t solve. – bmike Dec 01 '19 at 13:48

1 Answers1

1

curl can do this automatically for you (see the beginning of man curl for more details about this):

curl -O https://c.m.com/r*/p*/R*/5*/5*/2*/O*/images/page[0000-9999].svgz

PS: This assumes you will expand r*/p*/R*/5*/5*/2*/O*/ before running curl,

nohillside
  • 100,768
  • How would you do this for wget? – Joy Jin Mar 28 '20 at 13:13
  • 1
    @JoyJin wget doesn't directly support this. If there is an index/root page you could run wget -r -l 99 https://host/index, or you could try wget https://c.m.com/r*/p*/R*/5*/5*/2*/O*/images/page00{0..9{0..9}.svgz for the pages 0000 til 0099. – nohillside Mar 28 '20 at 13:49