Using the Google SOAP Search API - Cached Pages
(Page 3 of 4 )
The SOAP Search API service also gives developers access to Google's cache of pages. The process is simple enough; it involves a call to the doGetCachedPage method of the GoogleSearchService class. The method takes two arguments, your license key and the page to retrieve. An array of bytes is returned:
byte[] page = google.doGetCachedPage("x0x0",
"http://aspfree.com");
We can easily get the size of the cached page by checking the size of the array, and converting the array into a string isn't very complicated either. We simply have to call a static method of the System.Text.UTF8Encoding class:
Console.WriteLine("Page is {0} bytes.", page.Length);
Console.WriteLine("n" + UTF8Encoding.UTF8.GetString
(page));
Spelling Suggestions
Google's spelling suggestion service, like Google's cache of pages, is easy to make use of. The doSpellingSuggestion method takes only two arguments. The first is, of course, your license key, and the second is the word you wish to run through Google. If Google has a spelling suggestion, that suggestion is returned as a string, as in this example:
string spelling = google.doSpellingSuggestion("x0x0",
"choclate");
Console.WriteLine(""choclate" -> "{0}"", spelling);
However, if Google does not have a suggestion, then an empty string is returned, as in this next example:
string spelling2 = google.doSpellingSuggestion("x0x0",
"computer");
Console.WriteLine(""computer" -> "{0}"", spelling2);
Next: Asynchronous Calls >>
More Google Optimization Articles
More By Peyton McCullough