Skip to content

Instantly share code, notes, and snippets.

@canabady
Last active April 1, 2020 09:46
Show Gist options
  • Save canabady/19a16e773292e930d3cd2766e51c8caa to your computer and use it in GitHub Desktop.
Save canabady/19a16e773292e930d3cd2766e51c8caa to your computer and use it in GitHub Desktop.
To Retrieve all PDF anchor links from a webpage
# To retrieve All PDF anchors links from a web page
var pdflinks =[];
Array.prototype.map.call(document.querySelectorAll("a[href$=\".pdf\"]"), function(e, i){if((pdflinks||[]).indexOf(e.href)==-1){ pdflinks.push( "wget -O " + e.text.replace(/\s+$/, '').replace(/ /g,"_") + ".pdf " + e.href ); } });
console.log(pdflinks.join("\n"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment