Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Net::HTTP.get_print

get_print(uri_or_host, path_or_headers = nil, port = nil)

Gets the body text from the target and outputs it to $stdout. The target can either be specified as (uri, headers), or as (host, path, port = 80); so:

Example
Net::HTTP.get_print URI('http://www.example.com/index.html')

or:

Example
Net::HTTP.get_print 'www.example.com', '/index.html'

you can also specify request headers:

Example
Net::HTTP.get_print URI('http://www.example.com/index.html'), { 'Accept' => 'text/html' }