Google自定义搜索图片返回500错误

jum*_*noz 8 search-engine google-custom-search web google-image-search

大约40小时前开始,用于图片搜索的Google自定义搜索(searchType = image)始终返回500错误.我已经仔细检查了API文档,似乎没有任何变化.正如你在这个论坛中看到的那样,这影响了很多人.

https://productforums.google.com/forum/#!category-topic/customsearch/troubleshooting-and-bugs/4bJPzGPLYfw

这是我回复的全部内容:

{
   "error": {
       "code": 500,
       "message": null
   }
}
Run Code Online (Sandbox Code Playgroud)

我曾试图打电话给Google,但他们只是将我重定向到了绝对没有相关信息的网站.

有没有人设法让这个工作或与谷歌的人交谈过?我们正在大量使用这个功能,并且长期使用这个功能非常昂贵.

Pau*_*gen 1

我们通过删除 searchType=image 并更改代码来遍历 json 来解决这个问题。下面的代码更改传达了这样的想法:

从:

$.each(response.items, function(index, item) {
      images.push(item.link);
  });
Run Code Online (Sandbox Code Playgroud)

到:

  $.each(response.items, function(index, item) {
    if ((item.pagemap) && (item.pagemap.cse_image) && (item.pagemap.cse_image[0]) && (item.pagemap.cse_image[0].src)) {
      images.push(item.pagemap.cse_image[0].src);
    }
  });
Run Code Online (Sandbox Code Playgroud)

希望有帮助。

PS:不酷,谷歌,不酷。

编辑:上述解决方法可能不是您正在搜索的内容,因为图像的 Google 自定义搜索 (CSE) 又开始工作了(发布了大约 3 天,于 +/- 12/12/2014 恢复)。