Skip to content

Instantly share code, notes, and snippets.

@thecaffeinedev
Last active January 24, 2022 02:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thecaffeinedev/5e6d0ff9409344f88248bd8066226f68 to your computer and use it in GitHub Desktop.
Save thecaffeinedev/5e6d0ff9409344f88248bd8066226f68 to your computer and use it in GitHub Desktop.
Download Image URLs in a file Google Images
urls = Array.from(document.querySelectorAll('.rg_di .rg_meta')).map(el=>JSON.parse(el.textContent).ou);
window.open('data:text/csv;charset=utf-8,' + escape(urls.join('\n')));
@Alpha-T30
Copy link

Alpha-T30 commented Feb 7, 2021

not working on chrome incognito window , load an empty 'download' file

@thecaffeinedev
Copy link
Author

Hye @Alpha-T30

Try this code

var urls=Array.from(document.querySelectorAll('.rg_i')).map(el=> el.hasAttribute('data-src')?el.getAttribute('data-src'):el.getAttribute('data-iurl'));
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(urls.join('\n'));
hiddenElement.target = '_blank';
hiddenElement.download = 'myFile.txt';
hiddenElement.click();

@sandeepvm16
Copy link

even this giving an empty file

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