Home   Cover Cover Cover Cover
 

Using the Google Web Service

First go to http://www.google.com/apis/ and register for a key. Also download the WSDL for the Google web service as well as the documentation. Note that you can use the Google web service under this license.

Generate a proxy class GoogleProxy.cs from the WSDL description as follows:

  wsdl /out:GoogleProxy.cs GoogleSearch.wsdl

The client for calling the Google web service could then look like this:

Search.cs
using System;

class Test {
  static void Main(string[] args) {
    // insert the key that you got from Google.com after
    // registering at http://www.google.com/apis/
    string key = "...";
    
    // get the first 10 search results for the term that was
    // specified as a command-line argument
    Google.GoogleSearchService s = new Google.GoogleSearchService();
    Google.GoogleSearchResult r = s.doGoogleSearch(key, "arg[0]", 0, 10, false, "", false, "", "", "");
    foreach (Google.ResultElement elem in r.resultElements)
      Console.WriteLine(elem.URL);
  }
}