Google Custom Search API - 反向图片搜索

时间:2015-01-26 20:39:09

标签: google-custom-search

我收集了一些我缺少信息的图片。我希望能够进行Google反向图片搜索,以查找名称,关键字,类似图像的链接等。我知道抓取搜索结果页面是针对TOS的,并且已经得到了使用自定义的建议搜索API是正确的方法,但我没有在详细说明反向图像搜索的文档中找到任何内容。如果可以通过API实现这一点,是否有人能够指出我正确的方向,或者确认它是否支持?

非常感谢!

2 个答案:

答案 0 :(得分:2)

至于目前的API,我没有发现任何反向图像搜索功能。除了基于字符串的查询之外甚至没有您可以在自定义搜索的详细API参考中查找自己。

  

https://developers.google.com/custom-search/docs/xml_results

     

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

因此Google-custom-search不提供该功能。

在查看提供的其他API之后,它们都没有提供此功能。尝试查看Google支持的所有不同类型的API:

  

https://developers.google.com/apis-explorer/#p/

因此得出结论,没有反向图像搜索通过API形式谷歌。 (这可能会改变,我不能说什么,看看上面提供的链接)

某些供应商提供付费apis。

  

TinEye API https://services.tineye.com/TinEyeAPI

     

白炽灯http://incandescent.xyz/pricing/

否则你必须要求谷歌原谅你的宠物项目的小TOS违规行为:)

答案 1 :(得分:0)

SerpApi 是第三方解决方案,支持抓取 Google 反向图像。这是一个免费试用的付费 API。

例如,让我们使用 Danny DeVito 的这张图片:https://i.imgur.com/HBrB8p0.png

示例 Python 代码(也可在其他库中使用):

from serpapi import GoogleSearch

params = {
  "engine": "google_reverse_image",
  "google_domain": "google.com",
  "image_url": "https://i.imgur.com/HBrB8p0.png",
  "api_key": "secret_api_key"
}

search = GoogleSearch(params)
results = search.get_dict()

JSON 响应示例:

...
"image_results": [
  {
    "position": 1,
    "title": "Danny DeVito - Wikipedia",
    "link": "https://en.wikipedia.org/wiki/Danny_DeVito",
    "displayed_link": "https://en.wikipedia.org › wiki › Danny_DeVito",
    "snippet": "Daniel Michael DeVito Jr. (born November 17, 1944) is an American actor, comedian, director, producer, and screenwriter. He gained prominence for his ...",
    "cached_page_link": "https://webcache.googleusercontent.com/search?q=cache:EVb7AC9xwHYJ:https://en.wikipedia.org/wiki/Danny_DeVito+&cd=1&hl=en&ct=clnk&gl=us",
    "related_pages_link": "https://www.google.com/search?q=related:https://en.wikipedia.org/wiki/Danny_DeVito&sa=X&ved=2ahUKEwi7uom3wJ_xAhWxHDQIHct6DmQQHzAAegQIBhAQ"
  },
  {
    "position": 2,
    "title": "Danny DeVito - IMDb",
    "link": "https://www.imdb.com/name/nm0000362/",
    "displayed_link": "https://www.imdb.com › name",
    "snippet": "Danny DeVito, Actor: Matilda. Danny DeVito has amassed a formidable and versatile body of work as an actor, producer and director that spans the stage, ...",
    "cached_page_link": "https://webcache.googleusercontent.com/search?q=cache:c6r3v14HA7cJ:https://www.imdb.com/name/nm0000362/+&cd=2&hl=en&ct=clnk&gl=us"
  },
  {
    "position": 3,
    "title": "Danny DeVito - Simple English Wikipedia, the free encyclopedia",
    "link": "https://simple.wikipedia.org/wiki/Danny_DeVito",
    "displayed_link": "https://simple.wikipedia.org › wiki › Danny_DeVito",
    "thumbnail": "https://serpapi.com/searches/60cbb000ce87f8cca8f63685/images/9db7034fa3524b93ce0598116fd3b874800a67b8b9434cd54a009f2be5fd0809.jpeg",
    "thumbnail_destination_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/21/Danny_DeVito_by_Gage_Skidmore.jpg/1200px-Danny_DeVito_by_Gage_Skidmore.jpg",
    "image_resolution": "1200 × 1427",
    "snippet": "Daniel Michael \" · Danny\" · DeVito, Jr. (born November 17, 1944) is an American actor, director, producer and screenwriter. He has starred in and directed a number ...",
    "cached_page_link": "https://webcache.googleusercontent.com/search?q=cache:2DR2mxjaZbsJ:https://simple.wikipedia.org/wiki/Danny_DeVito+&cd=32&hl=en&ct=clnk&gl=us",
    "related_pages_link": "https://www.google.com/search?q=related:https://simple.wikipedia.org/wiki/Danny_DeVito&sa=X&ved=2ahUKEwi7uom3wJ_xAhWxHDQIHct6DmQQHzAfegQIFhAQ"
  },
  ...
]

查看documentation了解更多详情。

免责声明:我在 SerpApi 工作。

相关问题