如何使用Google API Ruby Client的Custom Search API的结果

时间:2014-05-19 03:56:35

标签: ruby google-api-ruby-client

我有这段代码

require 'google/api_client'
require 'google/api_client/client_secrets'
require 'google/api_client/auth/installed_app'

search_client = Google::APIClient.new(
  :application_name => 'Application'
)

google_search = search_client.discovered_api('customsearch')

# Load client secrets from your client_secrets.json.
client_secrets = Google::APIClient::ClientSecrets.load   

search_client.authorization = nil

response = search_client.execute(google_search.cse.list, 'q' => 'query')

在IRB中加载该文件后,我得到的结果如

#<Google::APIClient::Result:0xad56844>
=> true

我如何使用该结果,比如将其解析为有意义的内容?

1 个答案:

答案 0 :(得分:1)

在最后一行之后添加:

status, headers, body = response