Sunday, August 4, 2013

Download all files on a site

After tons of times I stumbled upon the problem of downloading many files listed on a single web page... after trying browser extensions, apps, and looking for a not too complicated bash script to use for the purpose... okay, I realized it's time to get hands dirty and write my definitive solution.

So here it is:
curl URL | grep -o http.*pdf | while read pippo; do wget $pippo; done 
Seems too simple, doesn't it?

I don't want to digress here about how it works: if you can't understand it, read
Actually, I didn't read the stuff above, just spotted what I needed!

You can easily modify the regular expression http.*pdf  to fit your needs (download different file formats etc).