These articles are more for me to save the code somewhere, so I can find it later on, but if you read this, waddup! I made a mini-script which adds a link under every pictures on an idealista ad so you can easily download them.

The problem

The pictures on idealista are protected, you can’t right-click on them and do “Save Image As…”, which means you need to get the URL from the source code and blablabla… it’s long.

The solution

First of all, visit the idealista property you want to download the images from and scroll down to ensure all the images are loaded (you might have to click on a “Show x next pictures”).

Second, right-click anywhere on the page and click Inspect, or go to the menu and do View > Developer > Inspect elements (you might not have these menus available as they are for web developers, check here how to show it).

Finally when you’ve opened the Inspect window, go to the Console tab, and copy and paste this code there.

The code basically we loop through all the divs with a specific class, then finds the img element in that div, get its src attribute, and then append a link to download the picture (and renames it so it’s not a URL).

// the specific class we mentioned above
$(".placeholder-multimedia").each(function(){
// getting image url, saved in variable called source
var source = this.getElementsByClassName("detail-image-gallery")[0].getAttribute("src");

// taking the innerHTML of the div and appending the <a> element to DL that delicious image
this.innerHTML += "<a href='" + source + "' download='" + source.substring(source.lastIndexOf('/') + 1) + "'>Download</a>";

// closing the loop
});

and, tada.

Every image should now have a Download link below. Simply alt + click the link and the image will download in your preferred folder (Downloads, usually).