Advertisement
Meetes

JS Get all PDFs links on a web page

Jun 19th, 2020
1,381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var pdflinks = [];
  2. Array.prototype.map.call(document.querySelectorAll("a[href$=\".pdf\"]"), function(e, i) {
  3.     if ((pdflinks || []).indexOf(e.href) == -1) {
  4.         pdflinks.push(e.href);
  5.     }
  6. });
  7. console.log(pdflinks.join(" "));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement