Retrieve Page Contents via Http Get using Ruby


This script retrieves the content of url and dumps it to the output .
Example copy this script into file named : get_page.rb

#!/usr/bin/ruby
require 'net/http'
host,port,url = ARGV
http = Net::HTTP.new(host, port)
STDERR.puts "url {#url}"
response, data = http.get(url)
puts data

Usage

ruby get_page.rb <host> <port> <url>

The url is specified as a relative path

ruby get_page.rb livrona.com 80 /news/home

 

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

Back to top