Google image search "automation"

Hi Experts,

I'm looking for input how to retrieve the top 1 image from a Google Image search.

The case study is this - a user enteres details for a vehicle, the manufacturer and model - then the webpage should display a image of the vehicle model. (actually the user enters the license plate, then a webservice retrieves the manufacturer + model - we'd like to show how the should loook like)

Any examples or ideas ?
Who is Participating?

Code update :
<!DOCTYPE html>
<html xmlns="">
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Search API Sample</title>
    <script src=""></script>
    <script type="text/javascript">

      google.load('search', '1');

      var imageSearch;
	  var nb = 1;

      function searchComplete() {

        // Check that we got results
        if (imageSearch.results && imageSearch.results.length > 0) {

          // Grab our content div, clear it.
          var contentDiv = document.getElementById('content');
          contentDiv.innerHTML = '';

          // Loop through our results, printing them to the page.
          var results = imageSearch.results;
          for (var i = 0; i < nb; i++) {
            // For each result write it's title and image to the screen
            var result = results[i];
            var imgContainer = document.createElement('div');
            var title = document.createElement('div');
            // We use titleNoFormatting so that no HTML tags are left in the 
            // title
            title.innerHTML = result.titleNoFormatting;
            var newImg = document.createElement('img');

            // There is also a result.url property which has the escaped version

            // Put our title + image in the content

          // Now add links to additional pages of search results.

      function searchOnClick() {
        // Create an Image Search instance.
        imageSearch = new;

        // Set searchComplete as the callback function when a search is 
        // complete.  The imageSearch object will have results in it.
        imageSearch.setSearchCompleteCallback(this, searchComplete, null);

        // Find me a beautiful car.
		var s = document.getElementById("terms").value;
        // Include the required Google branding'branding');

  <body style="font-family: Arial;border: 0 none;">
  	<input type="text" value="Subaru STI" id="terms" ><input type="button" value="search" onClick="searchOnClick();" />
    <div id="branding"  style="float: left;"></div><br />
    <div id="content"></div>

Open in new window

internetservice_dkAuthor Commented:
Perfect - couldnt google that up my self ;)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.