Skip to content

Instantly share code, notes, and snippets.

@bryant988
Last active October 16, 2026 08:33
Show Gist options
  • Select an option

  • Save bryant988/9510cff838d86dcefa3b9ea3835b8552 to your computer and use it in GitHub Desktop.

Select an option

Save bryant988/9510cff838d86dcefa3b9ea3835b8552 to your computer and use it in GitHub Desktop.
Zillow Image Downloader
/**
* NOTE: this specifically works if the house is for sale since it renders differently.
* This will download the highest resolution available per image.
*/
/**
* STEP 1: Make sure to *SCROLL* through all images so they appear on DOM.
* No need to click any images.
*/
/**
* STEP 2: Open Dev Tools Console.
* Copy and paste code below
*/
const script = document.createElement('script');
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
script.onload = () => {
$ = jQuery.noConflict();
const imageList = $('ul.media-stream li picture source[type="image/jpeg"]').map(function () {
const srcset = $(this).attr('srcset').split(' '); // get highest res urls for each image
return srcset[srcset.length - 2]
}).toArray();
const delay = ms => new Promise(res => setTimeout(res, ms)); // promise delay
// get all image blobs in parallel first before downloading for proper batching
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);
}
});
};
document.getElementsByTagName('head')[0].appendChild(script);
@legendaryroots

Copy link
Copy Markdown

This is a little bit of a smaller script that works if you open all images and scroll to the bottom, then run the script.

Works in active listings and sold listings as long as it has a modal with all of the pictures.

// === Zillow Vertical Media Wall Downloader ===
(async () => {
    // Scroll the wall so every lazy-loaded photo appears
    const wall = document.querySelector('ul[aria-label="media wall images"]');
    if (!wall) {
        alert("Couldn’t find the photo wall. Open the full gallery and scroll through all images first.");
        return;
    }
    wall.scrollIntoView({ behavior: "smooth" });
    await new Promise(r => setTimeout(r, 1200));

    // Get every JPEG source and pick the highest-resolution URL
    const sources = wall.querySelectorAll('picture source[type="image/jpeg"]');
    const urls = Array.from(sources).map(source => {
        const srcset = source.getAttribute('srcset');
        const parts = srcset.split(',').map(p => p.trim());
        const highest = parts[parts.length - 1].split(' ')[0]; // last entry = biggest size
        return highest;
    }).filter(Boolean);

    if (urls.length === 0) {
        alert("No photos found. Make sure you scrolled through the entire gallery.");
        return;
    }

    console.log(`Found ${urls.length} photos. Starting download...`);

    // Fetch all images as blobs (parallel, but browser is fine with it)
    const blobs = await Promise.all(
        urls.map(url => fetch(url).then(r => r.blob()))
    );

    // Download one by one with a small delay to keep Chrome happy
    for (let i = 0; i < blobs.length; i++) {
        const filename = `zillow-photo-${String(i + 1).padStart(3, '0')}.jpg`;

        const blobUrl = URL.createObjectURL(blobs[i]);
        const a = document.createElement('a');
        a.href = blobUrl;
        a.download = filename;
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);
        URL.revokeObjectURL(blobUrl);

        console.log(`✅ Downloaded ${filename}`);
        await new Promise(r => setTimeout(r, 350)); // gentle on the browser
    }

    console.log(`🎉 All ${urls.length} photos saved!`);
})();

@mkatychev

Copy link
Copy Markdown

@legendaryroots thank you so much for the updated script, this saved me a lot of time!

@rachelnd87

Copy link
Copy Markdown

Yeah I was getting mediaWall errors. So in summary, as of February 2025 this script worked for me after scrolling down to the bottom to load all the photos and pasting it in console. Combination of @jessereitz and @aarrtteemm's line update in one easy spot for copy paste:

const TARGET_FORMAT = "jpeg";  // Options: `jpeg` or `webp`
const TARGET_SIZE = "1536";  // Options: `1536`, `1344`, `1152`, `960`, `768`, `576`, `384`, `192`

// Load JSZip library
const script = document.createElement('script');
script.src = "https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js";
document.head.appendChild(script);

script.onload = function() {
    // Function to download the zip file
    function downloadZip(zip) {
        zip.generateAsync({type: 'blob'}).then(function(content) {
            const link = document.createElement('a');
            link.href = URL.createObjectURL(content);
            link.download = 'images.zip';
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
        });
    }

    // Function to gather and zip image URLs from "media wall"
    function gatherAndZipImages() {
        // Gather the image URLs
        const mediaWall = document.querySelector('div[data-testid="hollywood-vertical-media-wall"]');
        const sources = Array.from(mediaWall.querySelectorAll(`source[type="image/${TARGET_FORMAT}"]`));

        // Try to pull the largest src URL from a source's srcset
        // srcset is in the format "<url> <size>, <url> <size>" so we split it and try to grab the last (hopefully largest) URL
        // It shouldn't really matter, though, since the regex will replace the target size with the largest possible anyway
        const imageUrls = sources.map(source => {return source.srcset.split(",").at(-1).split(" ")[1].replaceAll(/_\d+.(jpg|webp)/g, `_${TARGET_SIZE}.${TARGET_FORMAT}`)});

        const zip = new JSZip();
        const imgFolder = zip.folder("images");

        if (imageUrls.length > 0) {
            console.log('Image URLs:', imageUrls);
            const downloadPromises = imageUrls.map((url, index) => {
                return fetch(url).then(response => response.blob()).then(blob => {
                    imgFolder.file(`image_${index + 1}.${TARGET_FORMAT}`, blob);
                });
            });

            Promise.all(downloadPromises).then(() => {
                downloadZip(zip);
            });
        } else {
            console.log(`No .${TARGET_FORMAT} images found.`);
        }
    }

    // Execute the function to gather and zip images
    gatherAndZipImages();
}

Thanks!

Excellent! Worked perfectly May 2026!

@McMilez

McMilez commented May 17, 2026

Copy link
Copy Markdown

Updated script here:
(() => {
const SCRIPT_NAME = "download-zillow-images.sh";
const FOLDER_NAME = "zillow-images";
const ZIP_NAME = "zillow-images.zip";

const found = new Map();

function cleanUrl(raw) {
if (!raw) return null;

try {
  const url = new URL(raw, location.href);
  url.search = "";

  if (!url.hostname.endsWith("zillowstatic.com")) return null;
  if (!url.pathname.includes("/fp/")) return null;
  if (!/\.(jpe?g|webp)$/i.test(url.pathname)) return null;

  return url.href;
} catch {
  return null;
}

}

function photoKey(url) {
const path = new URL(url).pathname;
return path.match(//fp/([^-./]+)/)?.[1] || path;
}

function qualityScore(url) {
const path = new URL(url).pathname.toLowerCase();

const numbers = [...path.matchAll(/[_-](\d{3,4})(?=[_.-]|\.(?:jpe?g|webp)$)/g)]
  .map(match => Number(match[1]));

const maxSize = numbers.length ? Math.max(...numbers) : 0;
const jpgBonus = /\.(jpg|jpeg)$/i.test(path) ? 25 : 0;

return maxSize * 100 + jpgBonus;

}

function add(raw) {
const url = cleanUrl(raw);
if (!url) return;

const key = photoKey(url);
const existing = found.get(key);

if (!existing || qualityScore(url) > qualityScore(existing)) {
  found.set(key, url);
}

}

function addSrcset(srcset) {
if (!srcset) return;

srcset.split(",").forEach(part => {
  const url = part.trim().split(/\s+/)[0];
  add(url);
});

}

document.querySelectorAll("img, source").forEach(el => {
add(el.currentSrc);
add(el.src);
addSrcset(el.srcset);
});

performance.getEntriesByType("resource").forEach(entry => {
add(entry.name);
});

const html = document.documentElement.innerHTML
.replaceAll("\u002F", "/")
.replaceAll("\/", "/")
.replaceAll("&", "&");

const urlRegex = /https?://photos.zillowstatic.com/fp/[^\s"'<>\]+?.(?:jpe?g|webp)/gi;
for (const match of html.matchAll(urlRegex)) {
add(match[0]);
}

const urls = [...found.values()];

if (!urls.length) {
console.log("No Zillow photo URLs found. Open the full photo gallery, scroll through the photos, then run this again.");
return;
}

const script = `#!/usr/bin/env bash
set -euo pipefail

mkdir -p "${FOLDER_NAME}"

cat > zillow-image-urls.txt <<'URLS'
${urls.join("\n")}
URLS

i=1

while IFS= read -r url; do
clean="${url%%\?}"
ext="${clean##
.}"

case "$ext" in
jpg|jpeg|webp) ;;
*) ext="jpg" ;;
esac

out=$(printf "${FOLDER_NAME}/image_%03d.%s" "$i" "$ext")
echo "Downloading $out"

curl -L --fail --retry 3 --connect-timeout 20 \
-A "Mozilla/5.0" \
-e "${location.href}" \
"$url" \
-o "$out"

i=$((i + 1))
done < zillow-image-urls.txt

zip -qr "${ZIP_NAME}" "${FOLDER_NAME}"
echo "Done: ${ZIP_NAME}"
`;

const blobUrl = URL.createObjectURL(
new Blob([script], { type: "text/x-shellscript" })
);

const link = document.createElement("a");
link.href = blobUrl;
link.download = SCRIPT_NAME;
document.body.appendChild(link);
link.click();
link.remove();

setTimeout(() => URL.revokeObjectURL(blobUrl), 5000);

console.log(Found ${urls.length} photos.);
console.log(Downloaded ${SCRIPT_NAME}.);
console.log("Then run this in Terminal:");
console.log(cd ~/Downloads && bash ${SCRIPT_NAME});
console.log("Photo URLs:", urls);
})();

@Divine-Overlord-Jawn

Copy link
Copy Markdown

@McMilez :(

Uncaught SyntaxError: expected expression, got '}'
debugger eval code:1
eval-with-debugger.js:304:22
getEvalResult resource://devtools/server/actors/webconsole/eval-with-debugger.js:304
evalWithDebugger resource://devtools/server/actors/webconsole/eval-with-debugger.js:218
evaluateJS resource://devtools/server/actors/webconsole.js:896
evaluateJSAsync resource://devtools/server/actors/webconsole.js:789
makeInfallible resource://devtools/shared/ThreadSafeDevToolsUtils.js:103
enter resource://devtools/server/actors/utils/event-loop.js:82
_pauseAndRespond resource://devtools/server/actors/thread.js:984
onDebuggerStatement resource://devtools/server/actors/thread.js:1970
debugger eval code:1

@osmancalisir

osmancalisir commented Oct 16, 2026 •

Copy link
Copy Markdown

Okay, here is my solution that works by Oct 15, 2026:

(async () => {
  // 1. Collect unique photo IDs from the page source
  const html = document.documentElement.innerHTML
    .replace(/\\u002F/g, '/')
    .replace(/\\\//g, '/');
  const re = /https:\/\/photos\.zillowstatic\.com\/fp\/([a-f0-9]{32})-[\w]+\.(?:jpg|webp)/g;
  const photos = new Map();
  let m;
  while ((m = re.exec(html))) if (!photos.has(m[1])) photos.set(m[1], m[0]);
  console.log(`Found ${photos.size} unique photos`);
  if (!photos.size) return console.warn('No photos found. Scroll the gallery and try again.');

  // 2. For each photo, try all known sizes and keep the largest file
  const files = [];
  let i = 0;
  for (const [hash, found] of photos) {
    i++;
    const candidates = [
      `https://photos.zillowstatic.com/fp/${hash}-o_a.jpg`,
      `https://photos.zillowstatic.com/fp/${hash}-uncropped_scaled_within_1536_1152.jpg`,
      `https://photos.zillowstatic.com/fp/${hash}-uncropped_scaled_within_1536_1152.webp`,
      `https://photos.zillowstatic.com/fp/${hash}-cc_ft_1536.jpg`,
      found,
    ];
    let best = null;
    for (const url of candidates) {
      try {
        const r = await fetch(url);
        if (!r.ok) continue;
        const data = new Uint8Array(await r.arrayBuffer());
        if (!best || data.length > best.data.length) {
          best = { data, ext: url.endsWith('.webp') ? 'webp' : 'jpg', url };
        }
      } catch (e) { /* try next */ }
    }
    if (best) {
      files.push({ name: `photo_${String(i).padStart(2, '0')}.${best.ext}`, data: best.data });
      console.log(`Downloaded ${i}/${photos.size} (${(best.data.length / 1024).toFixed(0)} KB) from ${best.url.split('-').pop()}`);
    } else {
      console.warn(`Photo ${i} failed`);
    }
  }
  if (!files.length) return console.error('All downloads failed (possibly blocked by CORS).');

  // 3. Minimal ZIP writer (store-only, images are already compressed)
  const table = new Uint32Array(256).map((_, n) => {
    for (let k = 0; k < 8; k++) n = n & 1 ? 0xEDB88320 ^ (n >>> 1) : n >>> 1;
    return n >>> 0;
  });
  const crc32 = (buf) => {
    let c = 0xFFFFFFFF;
    for (let i = 0; i < buf.length; i++) c = table[(c ^ buf[i]) & 0xFF] ^ (c >>> 8);
    return (c ^ 0xFFFFFFFF) >>> 0;
  };
  const enc = new TextEncoder();
  const parts = [], central = [];
  let offset = 0;
  for (const f of files) {
    const name = enc.encode(f.name);
    const crc = crc32(f.data);
    const lh = new DataView(new ArrayBuffer(30));
    lh.setUint32(0, 0x04034b50, true);
    lh.setUint16(4, 20, true);
    lh.setUint32(14, crc, true);
    lh.setUint32(18, f.data.length, true);
    lh.setUint32(22, f.data.length, true);
    lh.setUint16(26, name.length, true);
    parts.push(new Uint8Array(lh.buffer), name, f.data);

    const ch = new DataView(new ArrayBuffer(46));
    ch.setUint32(0, 0x02014b50, true);
    ch.setUint16(4, 20, true);
    ch.setUint16(6, 20, true);
    ch.setUint32(16, crc, true);
    ch.setUint32(20, f.data.length, true);
    ch.setUint32(24, f.data.length, true);
    ch.setUint16(28, name.length, true);
    ch.setUint32(42, offset, true);
    central.push(new Uint8Array(ch.buffer), name);

    offset += 30 + name.length + f.data.length;
  }
  const centralSize = central.reduce((s, p) => s + p.length, 0);
  const end = new DataView(new ArrayBuffer(22));
  end.setUint32(0, 0x06054b50, true);
  end.setUint16(8, files.length, true);
  end.setUint16(10, files.length, true);
  end.setUint32(12, centralSize, true);
  end.setUint32(16, offset, true);

  const blob = new Blob([...parts, ...central, new Uint8Array(end.buffer)], { type: 'application/zip' });

  // 4. Trigger download
  const slug = (location.pathname.match(/homedetails\/([^/]+)/) || [])[1] || 'zillow-listing';
  const a = document.createElement('a');
  a.href = URL.createObjectURL(blob);
  a.download = `${slug}-photos.zip`;
  document.body.appendChild(a);
  a.click();
  a.remove();
  console.log(`Done: ${files.length} photos zipped.`);
})();

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