Skip to content

Instantly share code, notes, and snippets.

@canabady
canabady / retrieve all pdf from a webpage
Last active October 8, 2024 17:26
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"));