Adding Google Search To Your Program using ASP.NET

In this post i will show you how to add google search program to your application.
  1. Download the Google API from and then follow the instructions to acquire a search key.
  2. Get the >NET SDK if you don't have it already and don't have VS.NET
  3. You can use the packaged Google api web service proxy or generate your own proxy class using the wsdl.exe util that comes packaged with ASP.NET SDK.
  4. Compile the proxy class using a command something like
    vbc /t:library /out:Google.dll Google.vb /r:System.web.dll /r:System.web.Services.dll / /r:system.dll /r:System.xml.dll (Note that for this we renamed the generated proxy class file to Google.vb mostly for clarity.)
  5. Next copy the generated Google.dll into the bin folder of your web app.
  6. Add an entry in Web.config to hold the google key you received -- in ours we put it in the appsettings section of web.config and called the key googlekey. Alternatively, you can hard-code the key in the search page.
  7. Write the search page - a sample of our code is shown in the next section
public void GoogleSearch()
   { objSearch = new;
       // Invoke the search method objResults =
 objSearch.doGoogleSearch("license-key-goes-here", "India", 0, 10, false, "", false, "", "", ""
       // Loop through result elements
       short shtCount;
       for (shtCount = 0; shtCount <= objResults.endIndex - 1; shtCount++)
MessageBox.Show(objResults.resultElements(shtCount).title +
 " - " + objResults.resultElements(shtCount).URL); }

1 comment:

  1. Overview

    The Google Custom Search API lets you develop websites and programs to retrieve and display search results from Google Custom Search programmatically. With this API, you can use RESTful requests to get either web search or image search results in JSON or Atom format.

    Important: The Google Custom Search API requires the use of an API key, which you can get from the Google APIs console. The API provides 100 search queries per day for free. If you need more, you may sign up for billing in the console.
    Available Documentation

    Version 1 is the latest available version of the Google Custom Search API. Its documentation includes:

    A Developer's Guide. Provides information on basic concepts and step-by-step instructions on how to use the common features of the API.

    This guide focuses on the RESTful method of invoking the API, or HTTP calls that use REST verbs (such as GET and POST) to access JSON or Atom data structures.

    You can access the documentation available for the Google Custom Search API below:
    API Version Developer's Guide Reference
    v1 Getting Started, Using REST Reference
    Free quota

    Usage is free for all users, up to 100 queries per day.
    Paid Usage

    Any usage beyond the free usage quota will fail if you are not signed up for billing. Once you have enabled billing, you will continue to receive 100 free queries per day. However, you will be billed for all additional requests at the rate of $5 per 1000 queries, for up to 10,000 queries per day.