Browse DevX
Sign up for e-mail newsletters from DevX


"Googlize" Your Java Apps to Search Billions of Web Pages

With the Google Web APIs service, a program can query more than 2 billion Web documents quickly and easily. Vikas Pandya uses a sample program to demonstrate how you can use the Google Web APIs service to program search engine functionality into your Java applications.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

oogle has introduced a Web API service that enables developers to program search engine functionality into their applications. With the Google Web APIs service, a program can query more than 2 billion Web documents quickly and easily. Applications with this functionality allow users to schedule regular search requests that can help monitor the Web for new information on a subject or offer comparative analyses of the amount of information available on different subjects over time.

The Google Web APIs service provides a SOAP (Simple Object Access Protocol) interface to search Google's index, accessing information and Web pages from its cache and checking the spelling of words against Google's standard search syntax. With its use of the SOAP and WSDL standards, Google allows developers to program in three environments: Java, Perl, or Visual Studio .NET. In this article, I use a sample program I coded (GoogleSearchDemo.java) to demonstrate how to use the Google Web APIs service with Java code.

Get Started
First you need to download the Google kit from http://www.google.com/apis/download.html. The free downloadable kit contains:

  • A complete API reference describing the semantics of method calls and fields
  • Sample SOAP request and response messages
  • A Google Web API WSDL file
  • A Java library, example program, and Javadoc documentation
  • A sample .NET program

Create a Google Web APIs service account. Use your account username and password to log in and get an account key. Note that Google limits each developer who registers for the Web APIs service to 1,000 queries per day.

Now you're ready to dive into the code. The following classes are included in the googleapi.jar file:

  • import com.google.soap.search.GoogleSearch; – The GoogleSearch class provides access to the Google Web APIs, as well as Google search functions and cached pages via SOAP.
  • import com.google.soap.search.GoogleSearchResult;GoogleSearchResult encapsulates presents the complete results from each Google Web APIs search call. You should call the get methods only on this object; the fields are filled in when a search result is returned.
  • import com.google.soap.search.GoogleSearchResultElement;GoogleSearchResultElement contains an individual search result component of a GoogleSearchResult.
  • import com.google.soap.search.GoogleSearchFault;GoogleSearchFault is an exception that encapsulates various errors that can result from a Google API call.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date