$ .getJSON Google Images displaying incorrect results

1

Based on this code:

function baixarCapa(capa, item) {
   $.getJSON("https://ajax.googleapis.com/ajax/services/search/images?callback=?", {
       q: '"' + capa + '"',
       v: '1.0'
   }, function(data) {
        var url = data.responseData.results[0].url;
        $('[data-capa=' + item + ']').html('<img src="' + url + '">');
    });
}

I can download artist images using the Google Images API, but the results are wrong in 50% of cases and are different from when I access the Google website and search for the same term.

$ .getJSON Behavior http://img.somdomato.com/imagens/top10.jpg

Why does this happen? How can I correct this behavior? Thank you.

    
asked by anonymous 05.02.2015 / 15:34

1 answer

1

I was looking for artist and music when the correct one would be only the artist. Changed:

capa = nome.split('/').pop();

To:

capa = nome.split('/').pop().split('-');

And use capa[0] instead of capa .

Thank you for your personal attention! In particular @rrnan

    
05.02.2015 / 16:31