[英]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.