HOW TO programmatically access all links on a web page

If you have to download files all files whose links are listed on a web page, this scripted method can accomplish the task faster (after some customization to the specific context) from the console tab of the Developer Tools feature of popular browsers -

Array.prototype.forEach.call(
    document.querySelectorAll("a.download[href*=x64]"),
    function (a) {
        console.log("wget " + a.href);
    });

With jQuery, it's even more terser -

$("a.download[href*=x64]").each(function () {
    console.log("wget " + this.href);
});

Comments