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.

Revisions

  1. callado4 revised this gist Sep 29, 2021. 1 changed file with 57 additions and 0 deletions.
    57 changes: 57 additions & 0 deletions realtor.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,57 @@
    /*
    Open up vertical photo gallery and scroll all the way to the bottom
    */

    const script33 = document.createElement('script');
    script33.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";

    script33.onload = () => {
    $ = jQuery.noConflict();

    function biggestSrc(srcset) {
    if (srcset == undefined) { return ""; }
    const srcs = srcset.split(' ');
    return srcs[srcs.length - 2];
    }

    const imageList = $('div.vertical-gallery-wrapper img').map((i,e) => biggestSrc($(e).attr('srcset'))).get();

    // const imgs = $('div.vertical-gallery-wrapper img')
    console.log('imageList', imageList.length, imageList);

    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);
    }

    let a = document.createElement('a');
    a.style = "display: none";
    console.log(i);

    let url = window.URL.createObjectURL(blobs[i]);
    a.href = url;
    const picNum = (i+1)
    if (picNum < 10) {
    a.download = '0' + picNum + '';
    } else {
    a.download = picNum + '';
    }
    document.body.appendChild(a);
    a.click();

    setTimeout(() => {
    window.URL.revokeObjectURL(url);
    }, 100);
    }
    });

    };

    document.getElementsByTagName('head')[0].appendChild(script33);
  2. callado4 revised this gist Sep 24, 2021. 1 changed file with 67 additions and 36 deletions.
    103 changes: 67 additions & 36 deletions zillow.js
    Original file line number Diff line number Diff line change
    @@ -7,54 +7,85 @@

    /**
    * STEP 1: Make sure to *SCROLL* through all images so they appear on DOM.
    * No need to click any images.
    */


    /**
    * STEP 2: Make sure to *SCROLL* through all images so they appear on DOM.
    * Click on the first image
    */

    /**
    * STEP 2: Open Dev Tools Console.
    * STEP 3: 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()))
    $ = jQuery.noConflict();

    // can't map since there isn't a list, so just push as we find more.
    const imageList = [];

    // while there is a next button
    while ($('svg.icon-arrow-right').length || $('svg.icon-reload').length) {
    const srcset = $('.hdp-photo-gallery-lightbox-content .hdp-gallery-image-content:visible source[type="image/jpeg"]').attr('srcset');
    console.log('srcset is', srcset);

    // no more images available so stop looping
    if (srcset == undefined) {
    break;
    }
    const srcs = srcset.split(' ');
    const src = srcs[srcs.length - 2];
    // just in case... let make sure the src is not already in the list.
    if (imageList.indexOf(src) === -1) {
    imageList.push(src);
    }
    // console.log('imageList is', imageList);
    // Last image, break out of loop
    if ($('svg.icon-reload').length) {
    break;
    }

    // go to the next slide
    $('svg.icon-arrow-right').parent().parent().click();
    }
    // console.log('imageList is', imageList);

    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);
    for (let i = 0; i < blobs.length; i++) {
    if (i % 10 === 0) {
    console.log('1 sec delay...');
    await delay(1000);
    }

    let a = document.createElement('a');
    a.style = "display: none";
    console.log(i);

    let url = window.URL.createObjectURL(blobs[i]);
    a.href = url;
    const picNum = (i+1)
    if (picNum < 10) {
    a.download = '0' + picNum + '';
    } else {
    a.download = picNum + '';
    }
    document.body.appendChild(a);
    a.click();

    setTimeout(() => {
    window.URL.revokeObjectURL(url);
    }, 100);
    }

    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);
  3. @bryant988 bryant988 revised this gist Apr 1, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion zillow.js
    Original file line number Diff line number Diff line change
    @@ -55,6 +55,6 @@ script.onload = () => {
    }, 100);
    }
    });
    }
    };

    document.getElementsByTagName('head')[0].appendChild(script);
  4. @bryant988 bryant988 revised this gist Apr 1, 2020. 1 changed file with 46 additions and 45 deletions.
    91 changes: 46 additions & 45 deletions zillow.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,7 @@
    /* NOTE: this specifically works if the house is for sale since it renders differently */
    /**
    * NOTE: this specifically works if the house is for sale since it renders differently.
    * This will download the highest resolution available per image.
    */



    @@ -10,50 +13,48 @@


    /**
    * 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
    * STEP 2: Open Dev Tools Console.
    * Copy and paste code below
    */
    $ = 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);
    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);
    }
    });
    }

    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);
  5. @bryant988 bryant988 revised this gist Mar 15, 2020. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions zillow.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    /* NOTE: this specifically works if the house is for sale since it renders differently */



    /**
    * STEP 1: Make sure to *SCROLL* through all images so they appear on DOM.
    * No need to click any images.
  6. @bryant988 bryant988 revised this gist Mar 15, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion zillow.js
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,8 @@ const imageList = $('ul.media-stream li picture source[type="image/jpeg"]').map(
    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(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++) {
  7. @bryant988 bryant988 revised this gist Mar 15, 2020. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions zillow.js
    Original file line number Diff line number Diff line change
    @@ -21,14 +21,13 @@ document.getElementsByTagName('head')[0].appendChild(jq);
    $ = 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(' ');
    const srcset = $(this).attr('srcset').split(' '); // get highest res urls for each image
    return srcset[srcset.length - 2]
    }).toArray();

    // promise delay
    const delay = ms => new Promise(res => setTimeout(res, ms));
    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) => {
  8. @bryant988 bryant988 created this gist Mar 15, 2020.
    55 changes: 55 additions & 0 deletions zillow.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    /**
    * 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);
    }
    });