Google created a search API web service that allow us to search billions of web pages from our own applications, those web services can be exposed from any programming environment such as .Net or java.
So the following are the needed steps for integrating with this service and small .Net sample .
- You can download the Developers Kit which contains .net and java samples and the wsdl file from the following Url.
- You must have google account 'gmail' in order to get the license key for using this API. So if you don't have an account you should go to the following link and create one.
or if you already have one just sign in and an email message containing the license key will be sent to you .
- After you get the license key you can start develop the application which we will mention in the following steps.
- Open Visual Studio .Net 2003 or 2005
- Choose new project and select the type and your preferred language ' we will choose win app with C# in our example'
- Right click in the solution explorer and choose add web reference and write the following url in the appeared dialog
And choose add reference as in the picture.
- Put in the form a textbox and change its ID to Txt_Text for the search and put a button and change it's ID to Btn_Search
- Drag and drop a datagrid if you are using 2003 or datagridview if 2005 .
- Write the following code under the Btn_Search _Click event.
com.google.api.GoogleSearchService s = new TestGoogle.com.google.api.GoogleSearchService();
com.google.api.GoogleSearchResult r = s.doGoogleSearch("put your lisence key her ", Txt_Text.Text, 0, 10, false, "", true, "", "", "");
int estimatedCount =r.estimatedTotalResultsCount;
DataTable dtResults = new DataTable();
dtResults.Columns.Add(new DataColumn("Title", typeof(string)));
dtResults.Columns.Add(new DataColumn("Summary", typeof(string)));
dtResults.Columns.Add(new DataColumn("URL", typeof(string)));
for (int i = 0; i < 10; i++)
DataRow dr = dtResults.NewRow();
dr = r.resultElements[i].title;
dr = r.resultElements[i].snippet;
dr = r.resultElements[i].URL;
dataGridView1.DataSource = dtResults;
This is the running application