S
sujeet kumar
hi
I am new to Ruby. I want to access http address using Ruby program .
I run the sample code of book The Pragmatic Programmer's Guide but it
doesn't work.
code is:
require 'net/http'
h =3D Net::HTTP.new('www.pragmaticprogrammer.com', 80)
resp, data =3D h.get('/index.html', nil )
puts "Code =3D #{resp.code}"
puts "Message =3D #{resp.message}"
resp.each {|key, val| printf "%-14s =3D %-40.40s\n", key, val }
p data[0..55]
Error is:
c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `initialize': getaddrinfo: no ad=
dress
associated with hostname. (SocketError)
from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `new'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `connect'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:55:in `timeout'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `connect'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:64:in `initialize'
from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `open'
from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `do_start'
from c:/ruby/lib/ruby/1.8/net/http.rb:419:in `start'
from c:/ruby/lib/ruby/1.8/net/http.rb:821:in `request'
from c:/ruby/lib/ruby/1.8/net/http.rb:615:in `get'
from url.rb:4
For information , I access internet through proxy server . Can anybody
tell me the error?
thanks
sujeet
I am new to Ruby. I want to access http address using Ruby program .
I run the sample code of book The Pragmatic Programmer's Guide but it
doesn't work.
code is:
require 'net/http'
h =3D Net::HTTP.new('www.pragmaticprogrammer.com', 80)
resp, data =3D h.get('/index.html', nil )
puts "Code =3D #{resp.code}"
puts "Message =3D #{resp.message}"
resp.each {|key, val| printf "%-14s =3D %-40.40s\n", key, val }
p data[0..55]
Error is:
c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `initialize': getaddrinfo: no ad=
dress
associated with hostname. (SocketError)
from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `new'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `connect'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:55:in `timeout'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `connect'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:64:in `initialize'
from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `open'
from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `do_start'
from c:/ruby/lib/ruby/1.8/net/http.rb:419:in `start'
from c:/ruby/lib/ruby/1.8/net/http.rb:821:in `request'
from c:/ruby/lib/ruby/1.8/net/http.rb:615:in `get'
from url.rb:4
For information , I access internet through proxy server . Can anybody
tell me the error?
thanks
sujeet