How to search for images in Google with JavaScript?

5

I'm developing a webpage where it was in the project's interest to display some Google images, where they would be displayed from some significant name.

I was reading something related and saw that Google Image Search API has been discontinued. Is there something similar or is it still possible to use this API for my purpose?

    
asked by anonymous 18.05.2014 / 00:10

2 answers

7

This code sucks, but it works. I made it quick because I saw that no one answered your question .. About the Google API, you will make some requests and you will have some errors, this API is paid, the API you sent above is obsolete, it is now the Custom Search that is in use. So if after a few tries you can not do it might be due to this charge.

Code:

<html>
<head>
    <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script></head><body><script>//UsandojQuerya=$.getJSON("http://ajax.googleapis.com/ajax/services/search/images?v=2.0&hl=pt-br&cr=countryBR&q=carros")
  .done(function( json ) {
    b = jQuery.parseJSON(a.responseText)
    for ( var i = 0; i < b.responseData.results.length; i++ ) {

        document.write("<img src='"+b.responseData.results[i].unescapedUrl+"' />");
}
  })
  .fail(function( jqxhr, textStatus, error ) {
    document.write("Erro ao capturar JSON");
});

</script>
    </body> 

</html> 

    
18.05.2014 / 04:20
2

My suggestion is you look for a specific image search service and the best I know is Flickr. Aside from the API being excellent, there is a huge database of images available.

This service , for example, is the default image search available on the site itself .

I hope I have helped.

    
18.05.2014 / 04:55