Java Reference
In-Depth Information
public class ScanLinks
{
/*
* The key that Google provides anyone who uses their API.
*/
static String key;
/*
* The search object to use.
*/
static GoogleSearch search;
/**
* This method queries Google for the specified search, all
* URL's found by Google are returned.
*
* @param query What to search for.
* @return The URL's that google returned for the search.
*/
public static Collection<GoogleSearchResultElement>
getResults(String query)
{
Collection<GoogleSearchResultElement> result =
new ArrayList<GoogleSearchResultElement>();
int resultCount = 0;
int top = 0;
do
{
search.setQueryString(query);
search.setStartResult(top);
GoogleSearchResult r = null;
try
{
r = search.doSearch();
} catch (GoogleSearchFault e)
{
e.printStackTrace();
}
if (r != null)
{
Object list[] = r.getResultElements();
resultCount = list.length;
for (int i = 0; i < resultCount; i++)
Search WWH ::




Custom Search