Google Search for .NET application

Published on by Inno Design

image

Today we are going to talk about building a software that search throgh google right from your desktop. There can be many application of such software like:

  • for making search engine for searching books in your ebook reader
  • for pdf reader you can give a search engine for direct download and reading purposes
  • for image download
  • for searching and downloading videos

Now let’s come to the point “HOW TO CODE”

well for making such application is very simple

you’ll need an API(Application platform installer) for fetching results from Google. here’s the link to get API

http://code.google.com/p/google-api-for-dotnet/downloads/detail?name=GoogleSearchAPI_0.3.1.zip&can=2&q=

The application needs framework 3.5

Now for searching make click event of search button as

private void button1_Click(object sender, EventArgs e)
{
flowLayoutPanel1.Focus();
flowLayoutPanel1.Controls.Clear();
web = new GwebSearchClient(referrer);
w_result= web.Search(textBox1.Text, 20, “en-us”);
flowLayoutPanel1.Height = this.Height – panel1.Height – panel2.Height-5;
for (int i = 0; i < w_result.Count; i++)
{
Label lblR = new Label();
lblR.Text = w_result[i].Title;
lblR.Width = flowLayoutPanel1.Width;
Label lblCon = new Label();
lblCon.Width = flowLayoutPanel1.Width;
lblCon.Text = w_result[i].Content;
lblCon.Top = lblR.Top + 10;
LinkLabel lnkUrl = new LinkLabel();
lnkUrl.Text = w_result[i].Url;
lnkUrl.Top=lblCon.Top+10;
lnkUrl.Width=flowLayoutPanel1.Width;
flowLayoutPanel1.Controls.Add(lblR);
flowLayoutPanel1.Controls.Add(lblCon);
flowLayoutPanel1.Controls.Add(lnkUrl);
}
}

I have taken flowlayout control for binding results

web is object of class “Google.API.Search.GwebSearchClient” provided with the API.

as you can see this is object of GwebSearchclient so it fetches the web results. in the same fashion you can extract image results by using GimageSearchClient, book results with GbookSearchClient etc

that’s all for today’s tips.

Happy coding :)

Published on Windows form

Comment on this post