PROGRAMMER DESK

July 3, 2009

Embed Google Search in Your Custom Applications

Filed under: Embed Google Search in Your Custom — vinayhatwal @ 5:36 am
Tags: , , ,

Embed Google Search in Your Custom Applications

Written by – Vinay Hatwal

Dt. 03-Jul-2009

 

Dear all,

This time I came with the topic “Embed Google Search in Your Custom Applications”. With this we can embed Google search in our application. First of all I will discuss the tools which you need to install on your PC to use the Google Search

 

  • .Net Framework 3.5
  • Google Search API for .NET 0.2  (GoogleSearchAPI_0.2.zip)
  • GoogleSearchAPI_0.2.zip
  • GoogleSearchAPI.dll

 

 

Steps to do

 

1)      Create a new project with vb.Net 2.0 or 3.5.(Windows Application)

2)      Add Reference of GoogleSearchAPI.dll

3)      Add following controls

  1. RichTextBox  – RichTextBox1
  2. Label- Label1
  3. TextBox- TextBox1         
  4. Button- Button1

4)      Your Interface will look like

inter1

 

5)      Add the following coding in your Form1.cs file

 

 

 

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ‘Declaring Generic IList for IWebResult Interface

        ‘You can use -

        ‘1) IWebResult

        ‘2) IVideoResult

        ‘3) INewsResult

        ‘4) INewsResult

        ‘5) IImageResult

        ‘ AND MORE

        Dim results As IList(Of Google.API.Search.IWebResult)

 

        ‘Taking result

        ‘calling of Google.API.Search.GwebSearcher.Search(search text, Number of search result would be returned at a time)

        results = Google.API.Search.GwebSearcher.Search(TextBox1.Text, 10)

        Dim str As String = “”

        RichTextBox1.Text = “”

        For Each r As Google.API.Search.IWebResult In results

            ‘Fetching Title

            str = str & “Title :” & r.Title & vbCrLf

            ‘Fetching URL

            str = str & “URL :” & r.Url & vbCrLf

            ‘Fetching VisibleUrl

            str = str & “VisibleUrl :” & r.VisibleUrl & vbCrLf

            ‘Fetching Content

            str = str & “Content :” & r.Content & vbCrLf

            str = str & “=========================================================================================” & vbCrLf

        Next

        RichTextBox1.Text = str

    End Sub

End Class

 

 

6)      Now Enter the text to search on text box and click on Go. The result will look like –

Search Result

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.