簡體   English   中英

是否有Ruby gem使用Google Images API?

[英]Is there a Ruby gem to use the Google Images API?

我需要在我的Rails應用程序上與Google Images API對話。 有沒有Ruby寶石可以做到這一點? 我發現了一個使用過時的API的舊gem。

有一個名為google_custom_search_api的寶石使用較新的谷歌自定義搜索API: https//github.com/wiseleyb/google_custom_search_api

您可以通過為searchType參數指定image來將其限制為圖像搜索,如下所示:

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

另外還有一個名為image_suckr的寶石 - https://github.com/maurimiranda/image_suckr你也可以直接在Google Image Search API中做類似的事情

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

您可以使用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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM