【问题标题】:Google Freebase API How To Get URL Of Image?Google Freebase API 如何获取图片的 URL?
【发布时间】:2013-05-19 19:18:53
【问题描述】:

所以,我想弄清楚如何获取 Freebase 数据库中图像的 URL。我想要一张旧金山的照片。这就是我获得旧金山主题的方式:

https://www.googleapis.com/freebase/v1sandbox/topic/%2Fen%2Fsan_francisco?key=MY_API_KEY

响应包含图片,例如:

{
    text: "San Francisco Skyline",
    lang: "en",
    id: "/m/04j74yh",
    creator: "/user/carmenmfenn1",
    timestamp: "2008-09-01T13:37:22.000Z"
}

然后我再次调用 GET API 来获取图像:

https://www.googleapis.com/freebase/v1sandbox/topic/%2Fm%2F04j74yh?key=MY_API_KEY

这会返回有关图像的大量信息,例如媒体类型、大小等。但我在那里看不到任何 URL。有一些 ID(blob id、mid)。我不确定如何继续获取图像的 URL。有什么想法吗?

这是完整的回复:

{
    id: "/m/04j74yh",
    property: {
        /common/image/appears_in_topic_gallery: {
            valuetype: "object",
            values: [
                {
                    text: "San Francisco",
                    lang: "en",
                    id: "/m/0d6lp",
                    creator: "/user/carmenmfenn1",
                    timestamp: "2008-09-01T13:37:22.000Z"
                }
            ],
            count: 1
        },
        /common/image/size: {
            valuetype: "compound",
            values: [
                {
                    text: "640.0 - 330.0 - Freebase Data Team - Rectangle Size",
                    lang: "en",
                    id: "/m/02bpzld",
                    creator: "/user/carmenmfenn1",
                    timestamp: "2008-09-01T13:37:22.000Z",
                    property: {
                        /measurement_unit/rect_size/x: {
                            valuetype: "float",
                            values: [
                                {
                                    text: "640.0",
                                    lang: "en",
                                    value: 640,
                                    creator: "/user/mwcl_images",
                                    timestamp: "2007-04-15T23:03:01.001Z"
                                }
                            ],
                            count: 1
                        },
                        /measurement_unit/rect_size/y: {
                            valuetype: "float",
                            values: [
                                {
                                    text: "330.0",
                                    lang: "en",
                                    value: 330,
                                    creator: "/user/mwcl_images",
                                    timestamp: "2007-04-15T23:03:01.001Z"
                                }
                            ],
                            count: 1
                        },
                        /type/object/attribution: {
                            valuetype: "object",
                            values: [
                                {
                                    text: "Freebase Data Team",
                                    lang: "en",
                                    id: "/m/0220tm0",
                                    creator: "/user/mwcl_images",
                                    timestamp: "2007-04-15T23:03:01.001Z"
                                }
                            ],
                            count: 1
                        },
                        /type/object/type: {
                            valuetype: "object",
                            values: [
                                {
                                    text: "Rectangle Size",
                                    lang: "en",
                                    id: "/measurement_unit/rect_size",
                                    creator: "/user/mwcl_images",
                                    timestamp: "2007-04-15T23:03:01.001Z"
                                }
                            ],
                            count: 1
                        }
                    }
                }
            ],
            count: 1
        },
        /common/licensed_object/license: {
            valuetype: "object",
            values: [
                {
                    text: "CC-BY-2.5",
                    lang: "en",
                    id: "/m/01xrw11",
                    creator: "/user/carmenmfenn1",
                    timestamp: "2008-09-01T13:37:22.000Z"
                }
            ],
            count: 1
        },
        /common/topic/notable_for: {
            valuetype: "object",
            values: [
                {
                    text: "Content",
                    lang: "en",
                    id: "/type/content"
                }
            ],
            count: 1
        },
        /common/topic/notable_types: {
            valuetype: "object",
            values: [
                {
                    text: "Content",
                    lang: "en",
                    id: "/type/content",
                    timestamp: "2013-05-17T00:04:43.942Z"
                }
            ],
            count: 1
        },
        /type/content/blob_id: {
            valuetype: "string",
            values: [
                {
                    text: "8debf723b25edb43b413bcb2890c4f4fe6ec5e5b2c7ce9c7e1f2aee273b0d0fe",
                    lang: "",
                    value: "8debf723b25edb43b413bcb2890c4f4fe6ec5e5b2c7ce9c7e1f2aee273b0d0fe",
                    creator: "/user/content_administrator",
                    timestamp: "2008-09-01T13:37:20.000Z"
                }
            ],
            count: 1
        },
        /type/content/length: {
            valuetype: "int",
            values: [
                {
                    text: "47162",
                    lang: "en",
                    value: 47162,
                    creator: "/user/content_administrator",
                    timestamp: "2008-09-01T13:37:20.000Z"
                }
            ],
            count: 1
        },
        /type/content/media_type: {
            valuetype: "object",
            values: [
                {
                    text: "image/jpeg",
                    lang: "en",
                    id: "/m/08x8",
                    creator: "/user/content_administrator",
                    timestamp: "2008-09-01T13:37:20.000Z"
                }
            ],
            count: 1
        },
        /type/object/attribution: {
            valuetype: "object",
            values: [
                {
                    text: "Freebase Staff",
                    lang: "en",
                    id: "/m/05g",
                    creator: "/user/content_administrator",
                    timestamp: "2008-09-01T13:37:20.000Z"
                }
            ],
            count: 1
        },
        /type/object/mid: {
            valuetype: "key",
            values: [
                {
                    text: "/m/04j74yh",
                    lang: "",
                    value: "/m/04j74yh"
                }
            ],
            count: 1
        },
        /type/object/name: {
            valuetype: "string",
            values: [
                {
                    text: "San Francisco Skyline",
                    lang: "en",
                    value: "San Francisco Skyline",
                    creator: "/user/carmenmfenn1",
                    timestamp: "2008-09-01T13:42:34.000Z"
                }
            ],
            count: 1
        },
        /type/object/type: {
            valuetype: "object",
            values: [
                {
                    text: "Image",
                    lang: "en",
                    id: "/common/image",
                    creator: "/user/content_administrator",
                    timestamp: "2008-09-01T13:37:20.000Z"
                },
                {
                    text: "Content",
                    lang: "en",
                    id: "/type/content",
                    creator: "/user/content_administrator",
                    timestamp: "2008-09-01T13:37:20.000Z"
                }
            ],
            count: 2
        },
        /type/object/guid: {
            valuetype: "string",
            values: [
                {
                    text: "#9202a8c04000641f80000000090393af",
                    lang: "",
                    value: "#9202a8c04000641f80000000090393af"
                }
            ],
            count: 1
        },
        /type/object/creator: {
            valuetype: "object",
            values: [
                {
                    text: "content_administrator",
                    lang: "",
                    id: "/user/content_administrator",
                    timestamp: "2008-09-01T13:37:20.000Z"
                }
            ],
            count: 1
        },
        /type/object/timestamp: {
            valuetype: "datetime",
            values: [
                {
                    text: "2008-09-01T13:37:20.000Z",
                    lang: "en",
                    value: "2008-09-01T13:37:20.000Z"
                }
            ],
            count: 1
        },
        /type/object/permission: {
            valuetype: "object",
            values: [
                {
                    text: "/boot/all_permission",
                    lang: "",
                    id: "/boot/all_permission"
                }
            ],
            count: 1
        }
    }
}

【问题讨论】:

    标签: web-services google-api freebase


    【解决方案1】:

    它有点隐藏在文档中,因为它没有自己的部分,而是从主题 API 文档中引用,但您可以找到必要的信息 here

    网址的格式为:

    https://usercontent.googleapis.com/freebase/v1/image/<image ID>
    

    【讨论】:

    • 默认情况下,这会返回一个非常小的图像。您可以添加 maxwidth 和 maxheight 参数使其更大:?maxwidth=225&maxheight=225&mode=fillcropmid
    • 我可以一次获取名称、图像和文本,而不是调用三次 api,而是调用三次 api 需要一段时间才能获取结果
    • 我不确定您在说什么文本,但如果是描述,您应该能够通过一次调用 MQLread 或主题 API 来获取它和名称。图像始终是一个单独的链接,即使在 HTML 中也是如此。当然,如果您尝试这样做,API 不适合批量下载。
    • @TomMorris 谢谢我明白了,我还想知道一件事,我能不能得到图像的数据类型,因为我也下载了图像,所以我需要用一些特定的类型保存跨度>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-04
    • 1970-01-01
    相关资源
    最近更新 更多