解析第一个Google结果android代码 [英] Parse 1st Google Result android code
问题描述
我希望有人给我一个示例代码,以仅解析第一个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:
- the URI format for a search
- Query parameters - you may need "num" parameter, as it specifies number of search results
Now you can start writing some code and come back if you have problems.
这篇关于解析第一个Google结果android代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!