首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Google Custom Search API -反向图像搜索

Google Custom Search API -反向图像搜索
EN

Stack Overflow用户
提问于 2015-01-27 04:39:09
回答 1查看 4.8K关注 0票数 22

我有一组我缺少信息的图片。我希望能够做一个谷歌反向图像搜索,以找到名称,关键字,链接到类似的图像,等等。我意识到抓取搜索结果页面是违反TOS的,并得到建议,使用自定义搜索API是正确的方式,但我还没有能够在文档中找到任何详细的反向图像搜索。有没有人能给我指出正确的方向,如果使用API是可能的,或者验证它是否实际上是受支持的?

非常感谢!

EN

回答 1

Stack Overflow用户

发布于 2021-06-18 04:33:36

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

例如,让我们使用丹尼DeVito的图像:https://i.imgur.com/HBrB8p0.png

示例python代码(也可以在其他库中找到):

代码语言:javascript
复制
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响应示例:

代码语言:javascript
复制
...
"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工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28158337

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档