我需要在我的Rails应用程序上使用Google Images API。有没有Ruby gem可以做到这一点呢?我发现了一个旧的gem,它使用了废弃的API。
发布于 2013-07-18 00:37:55
有一个名为google_custom_search_api的gem,它使用较新的谷歌自定义搜索API:https://github.com/wiseleyb/google_custom_search_api
您可以通过为searchType参数指定image来将其限制为图像搜索,如下所示:
results = GoogleCustomSearchApi.search("poker", {"searchType" => "image"})发布于 2013-10-24 07:08:57
还有另一个叫做image_suckr - https://github.com/maurimiranda/image_suckr的gem,你也可以直接在谷歌图片搜索API中做类似的事情。
suckr = ImageSuckr::GoogleSuckr.new
suckr.get_image_url({"q“=> "car"})
发布于 2019-04-07 07:55:00
你可以使用SerpApi gem来抓取谷歌图片的结果。您必须将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
https://stackoverflow.com/questions/9182933
复制相似问题