【问题标题】:Get image url google cse JSON获取图片 url google cse JSON
【发布时间】:2013-09-10 18:32:45
【问题描述】:

我正在尝试从 JSON CSE 检索图像但没有成功,我可以通过

检索标题和描述
  for (var i = 0; i < response.items.length; i++)
{
    var item = response.items[i];
    var title = item.htmlTitle;
...

但我无法从 JSON 中查询图像 url,这里是 JSON 架构:

"items": [
  {
   "kind": "",
   "title": "",
   "htmlTitle": "",
   "link": "",
   "displayLink": "",
   "snippet": "",
   "htmlSnippet": "",
   "cacheId": "",
   "formattedUrl": "",
   "htmlFormattedUrl": "",
   "pagemap": {
    "product": [
     {
      "name": "",
      "image": "",
      "description": ""
     }
    ],
    "cse_image": [
     {
      "src": ""
     }
    ],

我试过了:

item.pagemap.product.image
item.[pagemap][product].image
item.product.image
etc

请帮忙。

【问题讨论】:

    标签: javascript json google-custom-search


    【解决方案1】:

    看起来 product 是一个数组。你试过 item.pagemap.product[0].image 吗?

    【讨论】:

    • 对不起,没有帮助。出现错误:未捕获的类型错误:无法读取未定义的属性“0”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多