Programming the Google Web API with VB.NET

Create GUI and console Google search applications with Visual Basic and the .NET framework.

Along with the functionally identical C# [Hack #58] version, the Google Web APIs Developer’s Kit [Section 5.4] (dotnet/Visual Basic folder) includes a sample Google search in Visual Basic. While you can probably glean just about all you need from the Google Demo Form.vb code, this hack provides basic code for a simple console Google search application without the possibile opacity of a full-blown Visual Studio .NET project.

Tip

Compiling and running this hack requires that you have the .NET Framework (http://msdn.microsoft.com/library/default.asp?url=/nhp/default.asp?contentid=28000519) installed.

The Code

' googly.vb ' A Google Web API VB.NET console application ' Usage: googly.exe <query> ' Copyright (c) 2002, Chris Sells. ' No warranties extended. Use at your own risk. Imports System Module Googly Sub Main(ByVal args As String( )) ' Your Google API developer's key Dim googleKey As String = "insert key here" ' Take the query from the command-line If args.Length <> 1 Then Console.WriteLine("Usage: google.exe <query>") Return End If Dim query As String = args(0) ' Create a Google SOAP client proxy, generated by: ' c:\> wsdl.exe /l:vb http://api.google.com/GoogleSearch.wsdl Dim googleSearch As GoogleSearchService = New GoogleSearchService( ) ' Query Google Dim results As GoogleSearchResult = googleSearch. doGoogleSearch(googleKey, query, 0, 10, ...

Get Google Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.