Last active
October 8, 2024 17:26
-
-
Save canabady/19a16e773292e930d3cd2766e51c8caa to your computer and use it in GitHub Desktop.
To Retrieve all PDF anchor links from a webpage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
works like a charm! Thanks!