Skip to content

Instantly share code, notes, and snippets.

@richardcsuwandi
Last active July 31, 2020 09:14
Show Gist options
  • Save richardcsuwandi/ca7387d01407366b5b62d9b364e07765 to your computer and use it in GitHub Desktop.
Save richardcsuwandi/ca7387d01407366b5b62d9b364e07765 to your computer and use it in GitHub Desktop.
Javascript code to scrape Google Images URLs.
let urls = Array.from(document.querySelectorAll('.rg_i')).map(el=> el.hasAttribute('data-src')?el.getAttribute('data-src'):el.getAttribute('data-iurl'));
let hiddenElement = document.createElement('a');
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(urls.filter((value, index, arr) => { return value != null}).join('\n'));
hiddenElement.target = '_blank';
hiddenElement.download = 'download.csv';
hiddenElement.click();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment