Download all documents with a given extension in a web page using bash
June 19, 2019 ShellI used to have a python script that scrapes a given web page and downloads all the files with a given extension from the page. Today, not being able to find my script anymore, I tried to do a similar thing using bash only and interestingly, I was able to do a similar thing using a one-liner. Here is how it works:
1 lynx
Lynx is a hero of dumping web pages:
lynx -dump https://hadi.timachi.com/
2 grep
We pipe the result to grep with an extension for target files:
lynx -dump https://hadi.timachi.com/ | grep rar
3 wget
And finally, the amazing wget with backticks:
wget `lynx -dump https://hadi.timachi.com/ | grep rar`
And that is all, simple and nice.
Created: 2019-06-19 Wed 19:16