Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ruby Google issues

1 view
Skip to first unread message

theloc...@gmail.com

unread,
Dec 20, 2006, 2:18:31 AM12/20/06
to
I am having troubles with an example from the PickAxe Ruby book by Dave
Thomas.

Does this having anything to do with this recent key business, or
depreciated SOAP? Why am I getting a 502?

here is the code and output

require 'google'
require 'cgi'

key=File.read(File.join(ENV['HOME'], ".google_key")).chomp
google=Google::Search.new(key)
result=google.search('pragmatic')
printf "Estimated number of results is %d.\n",
result.estimatedTotalResultsCount
printf "Your query took %6f seconds. \n", result.searchTime
first=result.resultElements[0]
puts first.title
puts first.url
puts CGI.unescape(first.snippet)

and here is the output

/opt/local/lib/ruby/vendor_ruby/1.8/http-access2.rb:217:in
`get_content': Unexpected response: #<HTTP::Message::Headers:0x1659ef0
@response_status_code=502, @body_charset=nil, @request_uri=nil,
@header_item=[["Date", "Wed, 20 Dec 2006 07:07:59 GMT"],
["Content-Type", "text/html"], ["Server", "GFE/1.3"], ["Cneonction",
"Close"], ["Content-Length", "1403"]], @body_type=nil,
@request_method=nil, @chunked=false, @body_date=nil,
@request_via_proxy=nil, @http_version="1.1", @reason_phrase="Bad
Gateway", @body_size=0, @request_query=nil, @is_request=false>
(RuntimeError)

Manfred

unread,
Dec 20, 2006, 8:12:19 AM12/20/06
to

theloc...@gmail.com wrote:
> I am having troubles with an example from the PickAxe Ruby book by Dave
> Thomas.
>
> Does this having anything to do with this recent key business, or
> depreciated SOAP? Why am I getting a 502?
>
502 seems to be a load balancing problem on Googls side and is
experienced in irregular intervals. Please read and post to
http://groups.google.com/group/google.public.web-apis/browse_thread/thread/32a1dccd0bcda746/?hl=en#

Manfred

0 new messages