Java Reference
In-Depth Information
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++)
{
GoogleSearchResultElement element =
(GoogleSearchResultElement) list[i];
result.add(element);
}
}
top = top + 10;
} while ((resultCount >= 10) && (result.size() < 100));
return result;
}
/**
* Examine a sentence and see if it contains the word born
* and a number.
*
* @param sentence The sentence to search.
* @return The number that was found.
*/
private int extractBirth(String sentence)
Search WWH ::




Custom Search