Would you like to make your computer applications able to submit queries to Google and extract the data? For example, wouldn't it be nice to create an application that automatically queries Google with your keywords and returns the top 10 results? Then you'll want to take advantage of the Google SOAP Search API service. This article explains how.
Introduction
The Internet provides an unparalleled amount of information. However, without the aid of search engines such as Google, navigating through this information would be quite difficult. Search engines allow people to sift through billions of pages and find the information they need.
However, the use of search engines is not limited to people. Computer applications can easily query search engines and extract data. Google has made this process particularly easy with the Google SOAP Search API service. Though currently both in beta and under a restrictive license, Google's service is still worth taking a look at. Using the service, one can query Google as usual, but access to cached pages is also provided, as well as Google's spelling suggestion service.
Getting Started
To use Google's service, you first have to register and obtain a license key, which will be sent with each query:
https://www.google.com/accounts/NewAccount?
continue=http://api.google.com/createkey&followup=http://api.google.com/
createkey
If you have Visual Studio, create a project and then add a web reference to the SOAP Search API. This can be done by right clicking in the Solution Explorer and selecting “Add Web Reference.” A dialog will appear, where you can enter the WSDL file's URL:
http://api.google.com/GoogleSearch.wsdl
Name the reference “GoogleSearchService.” You'll need to point to this reference with a “using” statement in your code.
If you don't have Visual Studio, run the .NET SDK's wsdl utility:
wsdl http://api.google.com/GoogleSearch.wsdl
This will create a file called GoogleSearchService.cs. Use this file to access the SOAP Search API service.
To begin using the service, create a GoogleSearchService object. This will be used to interact with the service:
using System;
using System.Text;
using System.Text.RegularExpressions;
classGoogleSearchTest
{
static void Main()
{
GoogleSearchService google = new GoogleSearchService();
}
}
We'll be making use of this shell (and the namespaces it uses) throughout the article.
The remaining portion will be cover in next update.