locked
Google API for .NET RRS feed

  • Question

  • hello everybody,

     

    i need some help.

    i want to get result from google for my program that use visual bacis. it is work if my query is "algorithm" but it is doesn't work if my query is "define:algorithm". the goal of my program is to show the definition of a word or phrase.

    this is my code:

    Dim gwebsearcher As New Google.API.Search.GwebSearchClient("http://www.google.com")
    Dim results As IList(Of Google.API.Search.IWebResult) = gwebsearcher.Search("define:algorithm", 64)
          
    For Each item As Google.API.Search.IWebResult In results
         ListBox1.Items.Add(item.Content)

     

    is there anything wrong with my code?

     

    thanks

    Monday, March 28, 2011 11:04 PM

Answers

  • Hi,

    Your code does not return any results in the IList so you are not seeing anything.

     

    I couldn't see anything wrong with your code but as posted it needs a closing

    Next

     

    I tried this search which returned some results:>>

     

     Dim gwebsearcher As New Google.API.Search.GwebSearchClient("http://www.google.com")
     Dim results As IList(Of Google.API.Search.IWebResult) = gwebsearcher.Search("Microsoft", 1000, "English", "Off")
    
     For Each item As Google.API.Search.IWebResult In results
     ListBox1.Items.Add(item.Content)
     Next
    

     

     

    In case anyone else wants to try this then proceed as follows please.

     

    Download the 1st ZIP file:>>

    http://code.google.com/p/google-api-for-dotnet/downloads/list

     

    I put all the files into a NEW folder:>>

    C:\MyDLLs

     

    From the PROJECT menu I selected ADD REFERENCE... to GoogleSearchAPI.dll

    ( By using the BROWSE tab, navigate to the folder where the DLL is and then click on ADD )

     

    Then after adding one Button and one ListBox to a Form you can run this:>>


     

    Public Class Form1
    
    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
     Me.Text = "Working..."
    
     Dim gwebsearcher As New Google.API.Search.GwebSearchClient("http://www.google.com")
     Dim results As IList(Of Google.API.Search.IWebResult) = gwebsearcher.Search("Microsoft", 1000, "English", "Off")
    
     For Each item As Google.API.Search.IWebResult In results
     ListBox1.Items.Add(item.Content)
     Next
    
     Me.Text = "Done!!"
    
     End Sub
    
    End Class
    

     

     

     

    Thanks for your question and making me aware of these Google APIs.  :-)

     



    Regards,

    John

    Click this link to see how to insert a picture into a forum post.

    Installing VB6 on Windows 7



    • Proposed as answer by Kee Poppy Wednesday, April 6, 2011 3:22 AM
    • Edited by John Anthony Oliver Thursday, April 7, 2011 12:53 AM
    • Marked as answer by Kee Poppy Thursday, April 7, 2011 3:46 AM
    Tuesday, March 29, 2011 1:47 AM

All replies

  • Hi,

    Your code does not return any results in the IList so you are not seeing anything.

     

    I couldn't see anything wrong with your code but as posted it needs a closing

    Next

     

    I tried this search which returned some results:>>

     

     Dim gwebsearcher As New Google.API.Search.GwebSearchClient("http://www.google.com")
     Dim results As IList(Of Google.API.Search.IWebResult) = gwebsearcher.Search("Microsoft", 1000, "English", "Off")
    
     For Each item As Google.API.Search.IWebResult In results
     ListBox1.Items.Add(item.Content)
     Next
    

     

     

    In case anyone else wants to try this then proceed as follows please.

     

    Download the 1st ZIP file:>>

    http://code.google.com/p/google-api-for-dotnet/downloads/list

     

    I put all the files into a NEW folder:>>

    C:\MyDLLs

     

    From the PROJECT menu I selected ADD REFERENCE... to GoogleSearchAPI.dll

    ( By using the BROWSE tab, navigate to the folder where the DLL is and then click on ADD )

     

    Then after adding one Button and one ListBox to a Form you can run this:>>


     

    Public Class Form1
    
    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
     Me.Text = "Working..."
    
     Dim gwebsearcher As New Google.API.Search.GwebSearchClient("http://www.google.com")
     Dim results As IList(Of Google.API.Search.IWebResult) = gwebsearcher.Search("Microsoft", 1000, "English", "Off")
    
     For Each item As Google.API.Search.IWebResult In results
     ListBox1.Items.Add(item.Content)
     Next
    
     Me.Text = "Done!!"
    
     End Sub
    
    End Class
    

     

     

     

    Thanks for your question and making me aware of these Google APIs.  :-)

     



    Regards,

    John

    Click this link to see how to insert a picture into a forum post.

    Installing VB6 on Windows 7



    • Proposed as answer by Kee Poppy Wednesday, April 6, 2011 3:22 AM
    • Edited by John Anthony Oliver Thursday, April 7, 2011 12:53 AM
    • Marked as answer by Kee Poppy Thursday, April 7, 2011 3:46 AM
    Tuesday, March 29, 2011 1:47 AM
  • To anyone @ Microsoft,

    Have you got a similar DLL to get results from BING?

     



    Regards,

    John

    Click this link to see how to insert a picture into a forum post.

    Installing VB6 on Windows 7
    Tuesday, March 29, 2011 1:53 AM
  • Tuesday, March 29, 2011 3:19 AM
  •  

    Here  http://www.bing.com/toolbox/developers/

    Hi Crazypennie,

    Thanks for the link.  :-)

    I've marked your post as helpful.  ;-)



    Regards,

    John

    Click this link to see how to insert a picture into a forum post.

    Installing VB6 on Windows 7
    Tuesday, March 29, 2011 5:19 AM
  • thank you for the help..
    Saturday, June 25, 2011 7:47 AM
  • Thank you so much jhon. It's really helpfull.

    But I'm facing a problem with this code I can only retrive 64 results.

    I want to know Why it's return only 64 results? No 100 or 1000.

    Here is my code.

            Dim client As New GwebSearchClient("http://www.google.com")
            Dim results As IList(Of IWebResult) = client.Search("test", 1000, "English", "Off")
            For Each result As IWebResult In results
                ListBox1.Items.Add(result.title)
            Next
            Me.Text = ListBox1.Items.Count

    Thank You.

    Saturday, May 4, 2013 8:37 PM