解析第一个Google结果android代码 [英] Parse 1st Google Result android code

查看:119
本文介绍了解析第一个Google结果android代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人给我一个示例代码,以仅解析第一个Google搜索结果.
例如,我打开 http://google.com/search?sourceid=navclient& ; btnI = 1& q = microsoft .
该网址直接指向microsoft.com的网址.

如何解析确切的网址并将其保存为字符串?

谢谢.

解决方案

使用 JSON /Atom Google自定义搜索API .

简而言之,发送HTTP请求( JSON解析器)并瞧瞧!

您所需的基本上是Google搜索文档,因此请先阅读.请特别注意:

现在,您可以开始编写一些代码,如果遇到问题,请回来.

I would like somebody to give me an example code to parse only the first google result.
For example i open http://google.com/search?sourceid=navclient&btnI=1&q=microsoft.
This url goes direct to url of microsoft.com.

How can i parse the exact url and save it to a string?

Thank you in advance.

解决方案

Use JSON/Atom Google Custom Search API.

In short, send an HTTP request (HTTP GET in Android) with a query in REST format and you will get an HTTP response with search result in JSON format. Just parse the result (JSON parser) and voilà!

All you need is basically in Google Search documentation, so read it first. Pay special attention to:

Now you can start writing some code and come back if you have problems.

这篇关于解析第一个Google结果android代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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