Java Reference
In-Depth Information
The Google Search API allows access to Google search information. You can perform
any of the following using the Google search API:
• Spell check
• Search for a term
• View Googles cache for a site
• Find sites that link to a URL
• And more
In the next two sections, you will be shown how to make use of the Google Search API.
First, you will have to register with Google. Secondly, you will have to obtain Google's JAR file
that allows your Java application to access Google.
Registering for the Google API
When you request information from the Google API, you must send a key along with
your request. This key allows Google to track where requests are coming from. Before you
can use the Google Search API, you must register to obtain one of these keys. Once you reg-
ister with Google, your key will be mailed to you. To register with Google, visit the “Google
Developer Network.”
http://code.google.com/
The Google key is just a long stream of seemingly random characters. For example, the
Google key might look something like the following:
jWKfuw78WHdiwe8dfHs
This is not an actual Google key, and as a result would not work properly with the Google
Search API. To use any of the Google examples in this chapter, you will have to obtain a
Google API key of your own.
Using the Google API
The Google API provides a JAR file for you to use with your Java applications. You should
download this JAR file and include it with the classpath of any Java application that you
wish to use the Google API with.
For precise instructions on how to include the Google API with your Java project, refer to
the documentation that was included with the Google JAR file you downloaded. It will contain
up to date information on how to include the most current JAR file with your application.
Once you have added the Google JAR file to your application, you are ready to make use
of it. The Google JAR file provides several new classes for your applications to use. To access
these classes, you must import them with the following import command:
import com.google.soap.search.*;
Search WWH ::




Custom Search