Skip to content

Instantly share code, notes, and snippets.

@tchen
Last active January 8, 2024 07:30
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tchen/a844c589f3fab497ff930c116aa267e7 to your computer and use it in GitHub Desktop.
Save tchen/a844c589f3fab497ff930c116aa267e7 to your computer and use it in GitHub Desktop.
Extract Images From Zillow Home Views
/**
* Note: First, browser through all the images for the home. Then paste the following snippet into the console.
* Images will be saved to the download directory.
*/
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type.
$ = jQuery.noConflict();
var img = $('ul.photos li img').map(function(){return $(this).attr("src");});
img.map(function(idx){ $("body").append($("<a class='xyzxyz' href='"+img[idx]+"' download='"+img[idx].split('/')[4]+"' />")); console.log(idx); });
$('.xyzxyz').map(function(){ $(this)[0].click(); });
$('.xyzxyz').remove();
@GGLionCross
Copy link

GGLionCross commented Jan 17, 2022

Had to adjust the script, but this worked for me:

/**
 *  Note: First, browser through all the images for the home.
 *  Then paste the following snippet into the console.
 *  Images will be saved to the download directory.
 */
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";

document.getElementsByTagName('head')[0].appendChild(jq);

// ... give time for script to load, then type.
$ = jQuery.noConflict();
function download(url, filename) {
  fetch(url)
    .then(response => response.blob())
    .then(blob => {
      const link = document.createElement("a");
      link.href = URL.createObjectURL(blob);
      link.download = filename;
      link.click();
  })
  .catch(console.error);
}
var img = $('ul.media-stream li img').map(function(){return $(this).attr("src");});
img.map(function(idx){ download(img[idx], idx+".jpg"); console.log(idx); });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment