是否有Ruby gem使用Google Images API?

问题描述 投票:8回答:3

我需要在我的Rails应用程序上与Google Images API对话。有没有Ruby宝石可以做到这一点?我发现了一个使用过时的API的旧gem。

ruby ruby-on-rails-3 gem
3个回答
8
投票

有一个名为google_custom_search_api的宝石使用较新的谷歌自定义搜索API:https://github.com/wiseleyb/google_custom_search_api

您可以通过为image参数指定searchType将其限制为图像搜索,如下所示:

 results = GoogleCustomSearchApi.search("poker", {"searchType" => "image"})

1
投票

另外还有一个名为image_suckr的宝石 - https://github.com/maurimiranda/image_suckr你也可以直接在Google Image Search API中做类似的事情

suckr = ImageSuckr :: GoogleSuckr.new suckr.get_image_url({“q”=>“car”})


0
投票

您可以使用SerpApi gem来刮取Google图像结果。你必须将tbm参数设置为ishch

例如,要获取海豚图像:

require 'google_search_results' 

params = {
  q: "Dolphins",
  location: "Austin, Texas, United States",
  hl: "en",
  gl: "us",
  google_domain: "google.com",
  tbm: "isch",
}

query = GoogleSearchResults.new(params)
hash_results = query.get_hash

有关Google Images API的更多信息:https://serpapi.com/images-results

© www.soinside.com 2019 - 2024. All rights reserved.