Skip to content

Instantly share code, notes, and snippets.

@dhfromkorea
Last active August 29, 2015 14:07
Show Gist options
  • Save dhfromkorea/ad605f72583a9c370bfb to your computer and use it in GitHub Desktop.
Save dhfromkorea/ad605f72583a9c370bfb to your computer and use it in GitHub Desktop.
fetch all the links of files of a certain extension in a webpage.
// by default, it fetches pdf
// change pdf to an extension you want
var pdflinks = [];
Array.prototype.map.call(document.querySelectorAll("a[href$=\".pdf\"]"), function(e, i) {
if ((pdflinks || []).indexOf(e.href) == -1) {
pdflinks.push(e.href);
}
});
console.log(pdflinks.join(" "));
// copy the logged file names
// and paste it to Terminal in this format: 'wget -i file1 file2 file3'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment