Google Custom Search API are wonderful tools to create some awesome search engine like tools. Also if you want to add a search option to your website and customize the look and feel of your search results, Google Custom Search API serve best to you.
Ring in Spring with Stunning Lingerie from Journelle and get $25 OFF purchases of $200 or more! Use promo code: SPRING200. Offer valid 2/22/13-4/30/13. Shop Now
I have created a Real Time Search engine (I call it real time as it search as you type). I am really impressed by the speed/response of Google Search API.
I will show the code for one of the search api that I implemented in demo page. Let us see how to implement Web Search API.
In order to use Google Search API, you have to first generate a Key for you. Go to following page and signup your self for the Key.
Sign up for Google API Key
Step 2: Add HTML Container for Web Search
We will create a textbox and a button that will take input for search. And a DIV that will be populated by results:
When user will write a query and push Search button, a request will be made to Google Search using Custom Search API and the results are fetched. These results are then copied into the DIV.
The code in plain english is:
1. Create an object to connect Google Web search using class
2. Set a callback function that will get call once the results for the search are fetched.
3. Call the
execute() method with search query as argument.
4. In callback function, iterate through the results and copy it to container DIV.