小编Ahm*_*aba的帖子

当 searchType 为图像时,Google 自定义搜索 api 返回 0 个结果

我正在使用 Google 自定义搜索 API 来搜索图像。当我请求图像时,搜索结果始终为 0。我正在关注以下链接中的文档:

https://developers.google.com/custom-search/json-api/v1/reference/cse/list

根据文档,通过指定 searchType=images,api 只查找图像。

这是我的网址的样子:

https://www.googleapis.com/customsearch/v1?key=[API_Key]&cx=017576662512468239146:omuauf_lfve&searchType=image&q=cars

结果如下所示:

    {
 "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 - cars",
    "totalResults": "0",
    "searchTerms": "cars",
    "count": 10,
    "inputEncoding": "utf8",
    "outputEncoding": "utf8",
    "safe": "off",
    "cx": "017576662512468239146:omuauf_lfve",
    "searchType": "image"
   }
  ]
 },
 "searchInformation": {
  "searchTime": 0.049329,
  "formattedSearchTime": "0.05",
  "totalResults": "0",
  "formattedTotalResults": "0"
 }
}
Run Code Online (Sandbox Code Playgroud)

如果我从请求中删除 searchType,我会以网页的形式返回结果。这里有什么问题?

google-custom-search

4
推荐指数
1
解决办法
3991
查看次数

标签 统计

google-custom-search ×1