Using Google AJAX API to copy google results in array

This is some way you can get Google results as a JavaScript array that you can display on any page, you first need to get your Google API Key then try this code…

  1.         //generate new web search object
  2.         var searcher = new GwebSearch();
  3.         //disable html
  4.         searcher.setNoHtmlGeneration();
  5.         //expand results to max - about 10
  6.         searcher.setResultSetSize(GSearch.LARGE_RESULTSET);
  7.         //excute the search by adding keyword then collect the results in element with id='mydiv'
  8.         searcher.setSearchCompleteCallback( searcher.execute( 'my keyword' ),
  9.                                                                                 function()
  10.                                                                                 {
  11.                                                                                 var results = searcher.results;
  12.                                                                                 for(i in results)
  13.                                                                                         for(a in results[i])
  14.                                                                                                 document.getElementById("mydiv").innerHTML += results[i][a]+' | '} );
  15.  

More Description on how to collect information from this array could be found here


Tags :

This entry was posted on Sunday, January 28th, 2007 at 1:50 pm and is filed under Blog, Solutions. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “Using Google AJAX API to copy google results in array”

  1. GooHackle Says:

    Another way to do it, and with all the google results,it’s parsing the google results.

    You can do it with this online Google Parser

    Or read the complete post about it at: Get Google results in a list of clean URLs

 

Leave a Reply


 Top