Get webpage body by HTTPS

Hello,

I need to get the HTML content of a website which can be accessed by
HTTPS.
I tried to use

require ‘net/http’

uri=“https://website.com
url = URI.parse(uri)
req = Net::HTTP::Get.new(url.path)
https = Net::HTTP.new url.host, url.port
https.use_ssl true
res = https.start {|http|
http.request(req)
}
puts res.body

But I get an error saying that use_ssl is not defined in class Net:HTTP
(even if the documentation says other way).

Does anyone know what’s wrong?

Thanks

Hi,

You need to include the ssl part as well.

Julian.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs