Skip to content

Instantly share code, notes, and snippets.

@callado4
Forked from bryant988/zillow.js
Last active October 29, 2023 03:58
Show Gist options
  • Select an option

  • Save callado4/678385890df47a35553f11d948b34ec4 to your computer and use it in GitHub Desktop.

Select an option

Save callado4/678385890df47a35553f11d948b34ec4 to your computer and use it in GitHub Desktop.
Zillow Image Downloader
/**
* STEP 1: Make sure to *SCROLL* through all images so they appear on DOM.
* No need to click any images.
*/
/**
* STEP 2: Open Console.
* Add jquery scripts and give time for scripts to load.
*/
const 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);
/**
* STEP 3: Get image list and download files in increments of 10 due to avoid browser limitation
*/
$ = jQuery.noConflict();
const imageList = $('ul.media-stream li picture source[type="image/jpeg"]').map(function () {
// get highest res urls for each image
const srcset = $(this).attr('srcset').split(' ');
return srcset[srcset.length - 2]
}).toArray();
// promise delay
const delay = ms => new Promise(res => setTimeout(res, ms));
Promise.all(imageList.map(i => fetch(i))).then(responses =>
Promise.all(responses.map(res => res.blob()))
).then(async (blobs) => {
for (let i = 0; i < blobs.length; i++) {
if (i % 10 === 0) {
console.log('1 sec delay...');
await delay(1000);
}
var a = document.createElement('a');
a.style = "display: none";
console.log(i);
var url = window.URL.createObjectURL(blobs[i]);
a.href = url;
a.download = i + '';
document.body.appendChild(a);
a.click();
setTimeout(() => {
window.URL.revokeObjectURL(url);
}, 100);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment