当前位置: 代码迷 >> JavaScript >> 收拾下返回JSON的图片搜索的API
  详细解决方案

收拾下返回JSON的图片搜索的API

热度:609   发布时间:2013-11-01 14:43:02.0
整理下返回JSON的图片搜索的API

最近想测试volley的异步图片加载,每次都去找图片效果很不理想,下载了几个国外的demo,不是调的facebook的就是twitter,虽然可以VPN,但是感觉很不方便,国内的花了好久找了几个,都是不好使,最后找到这两个东西,谷歌和百度。

1、百度

参考地址(来自互联网):

http://image.baidu.com/i?tn=baiduimagejson&ct=201326592&cl=2&lm=-1&st=-1&fm=result&fr=&sf=1&fmq=1349413075627_R&pv=&ic=0&nc=1&z=&se=1&showtab=0&fb=0&width=&height=&face=0&istype=2&word=girl&rn=2&pn=1


这个地址比较长,删除一下参数:

http://image.baidu.com/i?tn=baiduimagejson&width=&height=&word=girl&rn=10&pn=2


几个关键参数:

width&height:长宽

word:查询关键词

rn:每页显示图片数量

pn:图片显示的页码


参考返回结果如下

{
    "queryEnc": "girl",
    "queryExt": "girl",
    "listNum": 1999,
    "displayNum": 21929725,
    "bdFmtDispNum": "约21,900,000",
    "bdSearchTime": "6.000",
    "bdIsClustered": "1",
    "data": [
        {
            "thumbURL": "http://t10.baidu.com/it/u=1025587248,1458534674&fm=59",
            "middleURL": "",
            "largeTnImageUrl": "http://t12.baidu.com/it/u=924334832,1400490131&fm=59",
            "hasLarge": 0,
            "hoverURL": "http://t11.baidu.com/it/u=1001163760,1466976252&fm=59",
            "pageNum": 1,
            "objURL": "http://www.widewallpapers.ru/mod/girls/3/1920x1200/hot-girl-wallpaper-1920x1200-008.jpg",
            "fromURL": "http://hdw.eweb4.com/out/687817.html",
            "fromURLHost": "http://hdw.eweb4.com",
            "currentIndex": "0",
            "width": 1920,
            "height": 1200,
            "type": "jpg",
            "filesize": "715",
            "bdSrcType": "5",
            "di": "0",
            "is": "0",
            "bdSetImgNum": 0,
            "bdImgnewsDate": "2013-02-01 13:22:13",
            "fromPageTitle": "<strong>girl</strong>",
            "fromPageTitleEnc": "<strong>girl</strong>",
            "bdSourceName": "",
            "bdFromPageTitlePrefix": "",
            "token": "0"
        },
        {
            "thumbURL": "http://t10.baidu.com/it/u=642396156,1965090283&fm=59",
            "middleURL": "",
            "largeTnImageUrl": "http://t10.baidu.com/it/u=636229272,1901199173&fm=59",
            "hasLarge": 0,
            "hoverURL": "http://t10.baidu.com/it/u=657566964,1952941079&fm=59",
            "pageNum": 2,
            "objURL": "http://www.mrwallpaper.com/wallpapers/blonde-girl-green-eyes-1920x1200.jpg",
            "fromURL": "http://hdw.eweb4.com/out/650129.html",
            "fromURLHost": "http://hdw.eweb4.com",
            "currentIndex": "0",
            "width": 1920,
            "height": 1200,
            "type": "jpg",
            "filesize": "436",
            "bdSrcType": "5",
            "di": "0",
            "is": "0",
            "bdSetImgNum": 0,
            "bdImgnewsDate": "2013-02-01 13:22:13",
            "fromPageTitle": "<strong>girl</strong>",
            "fromPageTitleEnc": "<strong>girl</strong>",
            "bdSourceName": "",
            "bdFromPageTitlePrefix": "",
            "token": "0"
        },
        {}
    ]
}

2、谷歌

谷歌就比较好了,地址如下:https://developers.google.com/image-search/v1/jsondevguide

参考查询地址:https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=girl

请求参数:https://developers.google.com/image-search/v1/jsondevguide#request_format

返回实例:

{
    "responseData": {
        "results": [
            {
                "GsearchResultClass": "GimageSearch",
                "width": "1024",
                "height": "768",
                "imageId": "ANd9GcRSKgavyK2uIEyZOKOmBM27QFmMoEZn6prf2eSLspHIJ43TUx2GWLEd6N_l",
                "tbWidth": "150",
                "tbHeight": "113",
                "unescapedUrl": "http://www.hdwpapers.com/walls/absolutely_innocent_princess_baby_girl_wallpaper-normal.jpg",
                "url": "http://www.hdwpapers.com/walls/absolutely_innocent_princess_baby_girl_wallpaper-normal.jpg",
                "visibleUrl": "www.hdwpapers.com",
                "title": "absolutely innocent princess baby 003cb003egirl003c/b003e wallpaper",
                "titleNoFormatting": "absolutely innocent princess baby girl wallpaper",
                "originalContextUrl": "http://www.hdwpapers.com/absolutely_innocent_princess_baby_girl_wallpaper-wallpapers.html",
                "content": "absolutely innocent princess baby 003cb003egirl003c/b003e wallpaper",
                "contentNoFormatting": "absolutely innocent princess baby girl wallpaper",
                "tbUrl": "http://t2.gstatic.com/images?q003dtbn:ANd9GcRSKgavyK2uIEyZOKOmBM27QFmMoEZn6prf2eSLspHIJ43TUx2GWLEd6N_l"
            },
            {
                "GsearchResultClass": "GimageSearch",
                "width": "1920",
                "height": "1080",
                "imageId": "ANd9GcQUnyHrVEbppqhZnWnQrijhBFP0X34gRf7pKw6PdT4ggepB2k9g-p71sgGh",
                "tbWidth": "150",
                "tbHeight": "84",
                "unescapedUrl": "http://static.hothdwallpaper.net/51baa511ad24454887.jpg",
                "url": "http://static.hothdwallpaper.net/51baa511ad24454887.jpg",
                "visibleUrl": "ch.hothdwallpaper.net",
                "title": "Beautiful 003cb003eGirls003c/b003e HD Arena桌布壁纸1920x1080 - 热门壁纸网",
                "titleNoFormatting": "Beautiful Girls HD Arena桌布壁纸1920x1080 - 热门壁纸网",
                "originalContextUrl": "http://ch.hothdwallpaper.net/wallpapers/hd/607550/beautiful-girls-wallpapers-hd-wallpapers-arena",
                "content": "Beautiful 003cb003eGirls003c/b003e HD Arena桌布壁纸1920x1080 - 热门壁纸网",
                "contentNoFormatting": "Beautiful Girls HD Arena桌布壁纸1920x1080 - 热门壁纸网",
                "tbUrl": "http://t2.gstatic.com/images?q003dtbn:ANd9GcQUnyHrVEbppqhZnWnQrijhBFP0X34gRf7pKw6PdT4ggepB2k9g-p71sgGh"
            },
            {
                "GsearchResultClass": "GimageSearch",
                "width": "614",
                "height": "500",
                "imageId": "ANd9GcQu8KfNqGL9v9ftBZze2GwKYknGKqGfdSfwEiszbfk7gQKOlP58-UqjgZH0",
                "tbWidth": "136",
                "tbHeight": "111",
                "unescapedUrl": "http://www.esquire.com/cm/esquire/images/SZ/esq-something-cool-we-saw-online-girl-habit-de.jpg",
                "url": "http://www.esquire.com/cm/esquire/images/SZ/esq-something-cool-we-saw-online-girl-habit-de.jpg",
                "visibleUrl": "www.esquire.com",
                "title": "Something Cool We Saw Online: 003cb003eGirl003c/b003e Habit - Esquire",
                "titleNoFormatting": "Something Cool We Saw Online: Girl Habit - Esquire",
                "originalContextUrl": "http://www.esquire.com/blogs/mens-fashion/girl-habit-tumblr-111612",
                "content": "Something Cool We Saw Online: 003cb003eGirl003c/b003e Habit - Esquire",
                "contentNoFormatting": "Something Cool We Saw Online: Girl Habit - Esquire",
                "tbUrl": "http://t1.gstatic.com/images?q003dtbn:ANd9GcQu8KfNqGL9v9ftBZze2GwKYknGKqGfdSfwEiszbfk7gQKOlP58-UqjgZH0"
            },
            {
                "GsearchResultClass": "GimageSearch",
                "width": "1920",
                "height": "1200",
                "imageId": "ANd9GcQzZsnXYPvBJuUpq_5QCEl3inUAYNBXx5SvZx2Vx63xTMnKvXXE5ub9pnTn",
                "tbWidth": "150",
                "tbHeight": "94",
                "unescapedUrl": "http://freefever.com/stock/girl-beautiful-wallpapers.jpg",
                "url": "http://freefever.com/stock/girl-beautiful-wallpapers.jpg",
                "visibleUrl": "www.freefever.com",
                "title": "003cb003eGirl003c/b003e Beautiful Wallpapers - 1920x1200 pixel Wallpaper #49068 003cb003e...003c/b003e",
                "titleNoFormatting": "Girl Beautiful Wallpapers - 1920x1200 pixel Wallpaper #49068 ...",
                "originalContextUrl": "http://www.freefever.com/wallpaper/1920x1200/girl-beautiful-wallpapers-49068.html",
                "content": "003cb003eGirl003c/b003e Beautiful Wallpapers - 1920x1200 pixel Wallpaper #49068",
                "contentNoFormatting": "Girl Beautiful Wallpapers - 1920x1200 pixel Wallpaper #49068",
                "tbUrl": "http://t2.gstatic.com/images?q003dtbn:ANd9GcQzZsnXYPvBJuUpq_5QCEl3inUAYNBXx5SvZx2Vx63xTMnKvXXE5ub9pnTn"
            }
        ],
        "cursor": {
            "resultCount": "7,330,000,000",
            "pages": [
                {
                    "start": "0",
                    "label": 1
                },
                {
                    "start": "4",
                    "label": 2
                },
                {
                    "start": "8",
                    "label": 3
                },
                {
                    "start": "12",
                    "label": 4
                },
                {
                    "start": "16",
                    "label": 5
                },
                {
                    "start": "20",
                    "label": 6
                },
                {
                    "start": "24",
                    "label": 7
                },
                {
                    "start": "28",
                    "label": 8
                }
            ],
            "estimatedResultCount": "7330000000",
            "currentPageIndex": 0,
            "moreResultsUrl": "http://www.google.com/images?oe003dutf80026ie003dutf80026source003duds0026start003d00026hl003dzh-CN0026q003dgirl",
            "searchResultTime": "0.20"
        }
    },
    "responseDetails": null,
    "responseStatus": 200
}


  相关解决方案