views:

491

answers:

4

I 'm trying to write a simple java desktop app to query google and get the results.I 've read so many articles in the past few days.I know that I have to do it through the gwt (google web toolkit) ,the api that google offers to programmatically query its search engine.My problem is that the gwt seems to be usefull only to construct ajax applications.I just want to write a simple desktop app.I am not interested in javascript ,xml or any server side application.Isn't there a way to do it?

+1  A: 

Sure, take a look at this approach.

The general idea is that you make an HTTP fetch (using vanilla java.net.HttpUrlConnection or Apache HTTP Client). The magic is in the forming of the URL with the search term, and in the processing of what you get back from Google.

For the exact details on how to do this, see Google's REST search API documentation, including this section.

Jim Ferrans
+1 for the design pattern approach, but if hes not willing to use XML, I doubt he'll be more willing to use design patterns.
monksy
@steven: You may be right. I've added in some lower level details on fetching pages from Java and on Google's published API.
Jim Ferrans
A: 

You can always get a license for the webservice and get the results returned through SOAP, however you did say that you were uninterested in XML. Shame, thats the quickest way. There is always doing a direct request to google through the query URL, since it uses HTTP get.

monksy
A: 

Take a look at this post

Bozho
+1  A: 

Where did you get that "I have to do it through the gwt (google web toolkit)"?

GWT is a framework to build AJAX applications using Java instead of Javascript.

Do you want to build a desktop (Swing) application or a web application??

GWT is NOT an API to query Google.

Iker Jimenez