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?

1
  • Merging files is very different answer than how to glob / abstract a pattern of file names. See apple.stackexchange.com/questions/99210/…? Or post a second question if you have an example of merging you can’t solve.
    – bmike
    Dec 1, 2019 at 13:48

1 Answer 1

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,

2
  • How would you do this for wget?
    – Joy Jin
    Mar 28, 2020 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, 2020 at 13:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .