如何通过桌面Java应用程序查询谷歌? [英] How to query google through desktop java app?

查看:110
本文介绍了如何通过桌面Java应用程序查询谷歌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个简单的Java桌面应用程序来查询Google并获得结果。过去几天我阅读过很多文章。我知道我必须通过GWT(Google Web Toolkit)这个Google提供的以编程方式查询其搜索引擎的API。我的问题是,GWT似乎只用于构建AJAX应用程序。我只想写一个简单的桌面应用程序。我对Javascript,XML或任何服务器端应用程序不感兴趣。有没有办法做到这一点?

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 useful 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?

推荐答案

当然,看看这种方法

总的想法是,你进行HTTP提取(使用vanilla java.net.HttpUrlConnection Apache HTTP客户端)。神奇之处在于用搜索词形成网址,以及处理从Google获取的内容。

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.

有关如何执行此操作的确切详情请参阅Google的 REST搜索API文档,其中包括< a href =http://code.google.com/apis/ajaxsearch/documentation/reference.html#_intro_fonje =nofollow noreferrer>本节。

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

这篇关于如何通过桌面Java应用程序查询谷歌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆