From: Eric Hodel Date: 2009-03-28T13:34:24+09:00 Subject: Re: https html parsing On Mar 27, 2009, at 21:13, Arun Kumar wrote: > Brian Candler wrote: >> Arun Kumar wrote: >>> /usr/lib/ruby/1.8/net/http.rb:560:in `initialize': getaddrinfo: >>> Name or >>> service not known (SocketError) >> ... >>> from example.rb:5 >>> This is the error which i get now when i use 'net/http'. >> >> This error isn't useful unless you also post your example.rb >> >> Note that in order to talk to a https server, you will need net/https >> not net/http. >> >> In some distributions (e.g. Ubuntu) you won't have net/https.rb until >> you install another package. For Ubuntu, apt-get install libopenssl- >> ruby > > Hi, > Thanks for ur reply. > > require 'net/https' > require 'uri' > > uri = "https://www.cia.gov" > url = URI.parse(uri) > req = Net::HTTP::Get.new('/', "User-Agent"=>"Mozilla/4.0 (compatible > MSIE 5.5; Windows NT 5.0)") > https = Net::HTTP.new(url.host, url.port) > https.use_ssl = true > res = https.start {|http| > http.request(req) > } > puts res.body > > This is my entire code of example.rb. Now i used https. I'm now > getting > a warning like this when i try to access https sites : > > warning: peer certificate won't be verified in this SSL session > > and i'm not able to access sites where the url is redirecting. This is explained in `ri Net::HTTP` under "Following Redirection"