Linux.com

scripting around wget

Posted by: Anonymous Coward on September 18, 2005 06:23 PM
The recursive options are nice but will not work if the web site does not explicitly link to the files you want to download.

For example, you are browsing www.dummy.net and notice 2 interesting images img/pict013.jpg and img/pict134.jpg.
More images of the form img/pict???.jpg may be available in that directory. Most sites will not allow you to get directory listings but you can scan using the following shell script:

A=1
while [ $A -lt 999 ] ; do

    N=`printf %03d $A`

    wget <a href="http://www.dummy.net/img/pict$N.jpg" title="dummy.net">http://www.dummy.net/img/pict$N.jpg</a dummy.net>

    let A=A+1
done

or if you are not afraid of typing a single long shell commands:

A=1; while [ $A -lt 999 ] ; do N=`printf %03d $A` ; wget <a href="http://www.dummy.net/img/pict$N.jpg" title="dummy.net">http://www.dummy.net/img/pict$N.jpg</a dummy.net><nobr> <wbr></nobr>;let A=A+1 ; done

NOTE: the [dummy.net] after the URL is inserted automatically ans so is not part of the command.

#

Return to CLI Magic: the word on wget