Tue 17 Oct 2006
Google Search API
Posted by datacrush under Techs
Google has a web service that allows developers to use Google search from within their own applications.
Using SOAP, a protocol for XML-based message exchange over HTTP layer, one could easily integrate an existing application with Google’s powerful web search capability. Web services can easily be accessed in .NET and Java applications. While it’s possible to use Web Services in ILE RPG, it is not something straightforward and I consider it more as a hack than a hard to get to feature.
The first thing to do is to obtain a license key to access Google’s API. At the moment the service allows 1000 automated search queries per day per license key.
Before you can begin writing an interface with Google’s API, you need to learn something called WSDL (pronounced wis-del). A WSDL is a formal definition or contract which is independent of platform and programming language. It defines the API and what you can do with it.
Having a WSDL reference allows you to code references like locally when it’s like totally on a remote machine.
Next, include the WSDL reference to your project. In Microsoft Visual Studio, you do this by adding a web reference under the Solution Explorer view. Coding is a breeze in this VB.NET example:
Dim MyService As Google.GoogleSearchService = …………New Google.GoogleSearchService() Dim MyResult As Google.GoogleSearchResult MyResult = MyService.doGoogleSearch(”license_key”, …………“datacrush“, 0, 10, False, “”, False, “”, “”, “”) Dim StartIndex As Integer = MyResult.startIndex Dim ResultE As Google.ResultElement = …………New Google.ResultElement ResultElement = MyResult.resultElements(2) MessageBox.Show(ResultElement.URL)
I’m sure someone else could write a much cleaner code snippet than that, but you get the idea. With proper use, one could write a useful application powered by Google.
Visit the API reference page for more information.