In the last two months, I visited google and learned what the great GFW has done. Although the form is not optimistic, it still shows that the dog released the google adsense api and google search ajax api. Obviously, the latter is more practical. Therefore, I applied for an api key by using thunder, but after referring to online manual, I 'd like to talk with the actual code:
Copy codeThe Code is as follows: function OnLoad (){
// Create a search control
Var searchControl = new GSearchControl ();
// Search option, which is set to auto expand
Var options = new GsearcherOptions ();
Options. setExpandMode (GSearchControl. EXPAND_MODE_OPEN );
// Added a Webpage Search
SearchControl. addSearcher (new GwebSearch (), options );
// Search result output options. GSearchControl. DRAW_MODE_TABED is another option in the list. Various search results are displayed in tab mode.
Var drawOptions = new GdrawOptions ();
DrawOptions. setDrawMode (GSearchControl. DRAW_MODE_LINEAR );
// Display 8 search results at a time
SearchControl. setResultSetSize (GSearch. LARGE_RESULTSET );
// Tell the searcher to draw itself and tell it where to attach
SearchControl. draw (document. getElementById ("searchcontrol"), drawOptions );
// Start searching
SearchControl.exe cute ("Google ");
}
The current version of this api is 0.1. After the official version 1.0 is released, there will be ads in the search results. Obviously, this lunch is not free.
- Here I wrote the demo (if not accessible, it means google is getting started again)-http://www.ooso.net/temp/demo/search.html
- Google AJAX Search API example
Http://code.google.com/apis/ajaxsearch/documentation/#AdvancedSamples