Retrieve Page Contents via Http Get
Posted August 16th, 2007 by administrator
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 /resource/home
A compact single line version can also be used
ruby -rnet/http -e 'Net::HTTP.get_print(URI.parse(ARGV[0]))' http://dzone.com/links/index.html













Comments
Post new comment