android - 如何在 json 数组中获取谷歌自定义搜索结果

标签 android json google-custom-search

我想在谷歌最新的自定义搜索中将谷歌搜索结果作为 json 数组。

如何实现代码。

例如:

 {
    "responseData": {` `
        "results": [
            {
      ` `          "GsearchResultClass ": "GwebSearch",
                "unescapedUrl": "http:/ / en.wikipedia.org/wiki/Paris_Hilton",
                "url"   : "http    ://    en.wikipedi a.org/wiki/Paris_Hilton",
                "visibleUrl  "  : "en.wikipedia .org",
                "cacheUrl    "    : "http://www.google.com/search?q=cache:TwrPfhd22hYJ:en.wikipedia.org",
                "title": "<   b>Paris Hilton</b   > - Wikipedia, the free encyclopedia",
                "titleNoFormatting": "Paris Hilton - Wikipedia, the free encyclopedia",
                "content": "[1] In 2006, she released her debut album..."
            },
            {
                "GsearchResultClass": "GwebSearch",
                "unescapedUrl": "http://`   `www.imdb.com/name/nm0385296/",
                "url": "http://`    `www.imdb.com/name/nm0385296/",
                "visibleUrl":     "www.imdb.com",
                "cacheUrl":      "http://www.google.com/search?q=cache:1i34KkqnsooJ:www.imdb.com",
                "title": "<b>    Paris Hilton</b>",
                "titleNoFormatting": "Paris Hilton",
                "content": "    Self: Zoolander. Socialite <b>Paris Hilton</b>..."
            }
        ]

最佳答案

如果您想要自定义搜索结果。 请阅读 Google 的 Custom Search Engine(免费):

Create custom search engine

然后转到链接以创建您的自定义搜索:

https://cse.google.com/cse/

或者

你应该去:

Google search API

点击链接:在 APIs Explorer 中试用此 API

插入您的参数:

  • https://www.googleapis.com/customsearch/v1 ?”
    • “q=”+关键字(例如:“Paris+Hilton”)
    • "&cx="+ 您的 cx 代码 CSE
    • "&key="+ 您授权的 API key [链接 API project , 点击: A project is needed to enable APIs + Create project, then go to 'APIs & auth' and activate in 'Custom Search API']
    • "num="+ 要返回的搜索结果数(整数)

Execute 显示 JSON 格式的结果。

关于android - 如何在 json 数组中获取谷歌自定义搜索结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38499946/

相关文章:

ListView 中的 Android Laggy AlphabetIndexer

Android USB 鼠标右键单击正确行为 (ICS)

javascript - 如何将 json 字符串转换为 google.visualization.DataTable?

google-custom-search - Google 自定义搜索查询参数和类别参数

android - 在 URL 上设置语言 Google 自定义搜索

Android Bluetooth Low Energy 获取对特定请求的响应

java - 我每次都在所有类(class)中使用一种方法。有没有办法只写一次这个方法?

javascript - Firebase Web 检索数据

objective-c - 如何在 iOS 中创建一个基本的 JSON 字符串

google-chrome - 如何将 google chrome 自定义搜索导出到 alfred 自定义搜索