Java Reference
In-Depth Information
{
System.out.println("ScanLinks [Google Key] [Site to Scan]");
} else
{
key = args[0];
search = new GoogleSearch();
search.setKey(key);
Collection<GoogleSearchResultElement> c =
getResults("\"" + args[1] + "\"");
for( GoogleSearchResultElement element:c)
{
StringBuilder str = new StringBuilder();
str.append(getLinkCount(element.getURL()));
str.append(":");
str.append(element.getTitle() );
str.append("(");
str.append(element.getURL());
str.append(")");
System.out.println(str.toString());
}
}
}
}
This recipe should be run with two parameters. The first parameter is the your Google
key, which was obtained from Google. The second parameter is the URL of the site you wish
to scan. For example, to scan the HTTP Recipes site you would use the following command:
ScanLinks [Google Key] [URL to Scan]
The above command simply shows where the abstract format to call this recipe, with the
appropriate parameters. For exact information on how to run this recipe refer to Appendix
B, C, or D, depending on the operating system you are using. The main method begins by
obtaining the key and passing it onto the GoogleSearch object.
key = args[0];
search = new GoogleSearch();
search.setKey(key);
Next, the URL to be scanned is passed to the getResults function. This function will
be discussed in the next section.
Collection<GoogleSearchResultElement> c =
getResults("\"" + args[1] + "\"");
Search WWH ::




Custom Search