Google url images won't download

I followed the directions in lesson 2, Went to google images, pulled up teddy images, pressed ctrl shift j,
showed an error:
Failed to load resource: the server responded with a status of 400 ()
so I still entered the two commands:
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’)));
gives me this output:
Window {postMessage: ƒ, blur: ƒ, focus: ƒ, close: ƒ, parent: Window, …}
and it will open a blank tab.
I did this several times, closed browser and reopened same result.
I am thinking something is wrong with my Chrome browser.
Lol, I need some help.

1 Like

I’m having the exact same issue, but I’m using Microsoft Edge not Chrome.

I no longer have an issue. The code works fine on Chrome.

Just had the same problem and found this workaround:

Try pasting this line into Chrome’s console:

urls = Array.from(document.querySelectorAll('.rg_di .rg_meta')).map(el=>JSON.parse(el.textContent).ou).join('\n');

You can then copy the console output to the clipboard using the ‘copy’ button.

1 Like

Thank you, it finally worked!

I had a similar issue on Chromium (Brave) and Firefox. So my workaround was this:

    urls = Array.from(document.querySelectorAll('.rg_i'))

    var arr = [];
    for (var i = 0 in urls) {
        var a = urls[i].src;
        if (a.includes('https')) {
            arr.push(a);
            }

    }

    window.open('data:text/csv;charset=utf-8,' + escape(arr.join('\n')));

Clumsy since js is not my native.

2 Likes

Thank you, guy! I can download image url from Google!

I’m having this problem too. I’m using Chrome on Chrome OS. None of the above suggestions have worked for me. Can anyone help?

Nevermind, this worked: Updated JS to scrape image urls

1 Like