在Google中搜索图片并获取JSON响应

时间:2016-02-08 14:18:30

标签: google-search google-image-search

我正在尝试使用以下

的关键字搜索谷歌图片

https://www.googleapis.com/customsearch/v1?searchType=image&key=my_custom_search_key&cx=my_custom_search_engine_key&q=love

但是我得到了以下json

{

    "kind": "customsearch#search",
    "url": {

        "type": "application/json",
        "template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json"

    },
    "queries": {

        "request": [

            {
                "title": "Google Custom Search - love",
                "totalResults": "0",
                "searchTerms": "love",
                "count": ​10,
                "inputEncoding": "utf8",
                "outputEncoding": "utf8",
                "safe": "off",
                "cx": "my_custom_search_engine_key",
                "searchType": "image"
            }
        ]

    },
    "searchInformation": {
        "searchTime": ​0.054318,
        "formattedSearchTime": "0.05",
        "totalResults": "0",
        "formattedTotalResults": "0"
    }

}

哪些不能提供图片的搜索结果,我需要获取图片的网址和JSON中的描述?

1 个答案:

答案 0 :(得分:0)

我找到了你的查询,但我的密钥和cx。但早些时候我有类似的问题,我的问题是https://cse.google.com/cse/setup/basic?cx= {YOUR_CX}
我将“图像搜索”设置为“开”。点击“更新”以保存更改。