I wanted to download all the mp3's from the
the Best of Bootie 2006 CD website, but there wasn't a way to download all the files at once. I got around this by doing the following in Firefox:
- Select all the text on the page containing links to the files.
- Right-click on the text that was just selected.
- Pick "View Selection Source".
- When the DOM Source of Selection opens, Right-click on the selected HTML and pick "Copy".
- Open a Terminal and "cd" to the location I want to save the files in.
- Type in the following command: "pbpaste | tr \> \\n | grep href | cut -d '"' -f 2 | xargs wget"
What this does:
- "pbpaste" is a Mac OS X command line utility that allows you to print out the clipboard ("xsel" is an equivalent in Linux). This prints out the HTML that I selected in step 4 above.
- "tr" replaces characters. I replaced the right angle bracket with a carriage return, so that every HTML tag was is on a separate line.
- "grep" searches text. I looked for "href" which gave me every link in the selected text
- "cut" can give you specific columns of text based on a separator you give it. I said to split at double quotes and give me the second column (the mp3).
- "xargs" takes input and will run a command with each input line as the argument of the command.