Javascript issue while downloading images

this was the only solution that worked for me, thanks a lot :slight_smile:

1 Like

only this solution worked for me

1 Like

thanks. out of 5 other solutions only this worked for me

Still I find that file empty.

try my code in Chrome
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.csv'; hiddenElement.click();

Hi,
I am stuck on the same problem. I tried all the solutions provided on this conversation but the links are encrypted and not similar in any way to what Jeremy showed in his lecture. The initial 10-12 lines in the file are blank and the links are like -
https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcRs_kltkyTFFAwOBwk0kzj3y9IaDCMV300BiqzzN0HZywy05zg9&usqp=CAU

Also, I am using Microsoft Edge Chromium, is it necessary to use Google Chorme?

Thanks!

Hi,

Generating the csv file after removing all the null urls solved the problem for me. Give it a try!

var urls=Array.from(document.querySelectorAll('.rg_i')).map(el=> el.hasAttribute('data-src')?el.getAttribute('data-src'):el.getAttribute('data-iurl'));
var filtered = urls.filter(function (el) {
  return el != null;
});
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(filtered.join('\n'));
hiddenElement.download = 'file.csv';
hiddenElement.click();

Unfortunately this will only get you a small size images that google downsized for the matrix display. To get the original size image one needs to click on the image, then a new “frame” opens where you can get the link to the original image. Unfortunately, I do not know the web scarping enough to make a javascript or python to put this procedure in a script.

After of digging 3 Hours this is the only with works for me. I used it in Chrome, Safary , Firefox

Thanks a Lot!!!

Check out this extension for Chrome:

much easier…

bro I have some problem about download the data into the urls in fastai library
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’)));

this might not work … in my side please helpe mee
if you have any other idea