• Post Reply Bookmark Topic Watch Topic
  • New Topic

Experience with Google Java API?

 
Erwin Heil
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need somebody with experiences with the Java API from Google.
I use the API to get an easy access to the Google Webservice.
Everything works accept the use of GoogleSearchResultElement!
How can I use e.g. getTitle() or getSnippet()? While calling these methods I get no result..
code snippet:
...
GoogleSearch s = new GoogleSearch();
s.setKey(clientKey);
...
if (directive.equalsIgnoreCase("Search")){
s.setQueryString(directiveArg);
// Invoking GoogleSearch
GoogleSearchResult r = s.doSearch();
System.out.println("Google Search Results:");
System.out.println("======================");
// here it comes...
GoogleSearchResultElement gsre = new GoogleSearchResultElement();
String st = gsre.getTitle();
String sn = gsre.getSnippet();
System.out.println("Title: "+st+" | Snippet: "+sn); //[IS NOT THERE!]
// Output [IS THERE!]
System.out.println(r.toString());
result = r.toString();
...
cheers, erwin
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!