Programming the Google Web API with C# and .NET
Create GUI and console Google search applications with C# and the .NET framework.
The Google Web APIs
Developer’s Kit Section 5.4 includes a sample
C# Visual Studio .NET (http://msdn.microsoft.com/vstudio/) project
for a simple GUI Google search application (take a look in the
dotnet/CSharp folder). The functional bits
you’d probably find most interesting are in the
Form1.cs code.
This hack provides basic code for a simple console Google search application similar in function (and, in the case of Java [Hack #56], form, too) to those in Perl [Hack #50], Python [Hack #57], et al.
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.cs // A Google Web API C# console application // Usage: googly.exe <query> // Copyright (c) 2002, Chris Sells. // No warranties extended. Use at your own risk. using System; class Googly { static void Main(string[] args) { // Your Google API developer's key string googleKey = "insert key here"; // Take the query from the command-line if( args.Length != 1 ) { Console.WriteLine("Usage: google.exe <query>"); return; } string query = args[0]; // Create a Google SOAP client proxy, generated by: // c:\> wsdl.exe http://api.google.com/GoogleSearch.wsdl GoogleSearchService googleSearch = new GoogleSearchService( ); // Query Google GoogleSearchResult results = googleSearch.doGoogleSearch(googleKey, ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access