谷歌自定义搜索API - 反向图像搜索

22

我有一组图片,但缺少相关信息,希望能够使用Google反向图像搜索来查找名称、关键词、类似图片的链接等。我知道抓取搜索结果页面是违反服务条款的,而且有建议使用自定义搜索API来完成这个功能,但我在文档中没有找到详细介绍反向图像搜索的内容。如果API支持此操作,有人能指导我正确的方向吗?或者验证一下它是否被支持?

非常感谢!


我还需要Google图像搜索(反向图像搜索)作为官方API。 - mesqueeb
2个回答

3

关于当前API,我没有发现任何反向图片搜索功能的提及,甚至除了基于字符串的查询之外什么都没有。您可以在自定义搜索的详细API参考中自行查看。

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

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

谷歌自定义搜索并没有提供此功能。
在查看了其他提供的API后,发现它们也都没有这个功能。尝试在这里查看谷歌支持的各种不同类型的API:

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

因此,结论是,无法通过Google的API进行反向图像搜索。(这可能会改变,我不能保证,可以查看上面提供的链接)
有一些供应商提供付费的API。
TinEye API https://services.tineye.com/TinEyeAPI Incandescent API http://incandescent.xyz/pricing/ 否则,你需要请求Google原谅你违反了小小的服务条款,以便完成你的个人项目 :)

有人能确认这仍然是事实吗(2018年12月)?不幸的是,我认为在这个答案之后的4年里,反向图像搜索并没有得到很大发展。 - StLia

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"
  },
  ...
]

查看文档以获取更多详细信息。

免责声明:我在SerpApi工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接