Reputation: 11
I'm looking at a web page with a bunch of pictures on it. Hundreds. I want to download all these pictures at full resolution in one go. If I right-click-save-as each picture, it will give me a lower-resolution picture than the highest-res one stored on the server.
However, the full res ones are referenced in the source code of the page when I 'Inspect Element'. Problem is they are scattered across a bunch of different classes and HTML attributes. Sometimes they are in the 'href' attribute. Sometimes in one called 'data-hd'.
Thankfully, each high-res image ends in "_1280.jpg". What I want is the full filename, which would be, for example, "media.website.com/folderstructurestuffhere/longalphanumericstringhere_1280.jpg"
So my question is:
How do I use Javascript to find every instance of a particular phrase (in this case, "_1280.jpg"), grab the full text/URL from whatever attribute contains that phrase, then write it to the console?
Upvotes: 0
Views: 45
Reputation: 1
How do I use Javascript to find every instance of a particular phrase (in this case, "_1280.jpg"),
$("img[src*=_1280\\.jpg], img[data-hd*=_1280\\.jpg]")
.each(function() {
console.log(this.src, this.dataset.hd)
})
Upvotes: 1