user1702595 user1702595 - 4 months ago 18
Ruby Question

How do I Express this PHP in Ruby?

I need a neat and tidy and elegant way to do this in Ruby. It is a simple get what is on teh page and out put it tot eh screen.

<!--?php
echo file_get_contents("http://www.google.com");
?-->

Answer

You can use net/http like this:

require 'net/http'
puts Net::HTTP.get('google.com', '/')

You can also use get_print, like this:

Net::HTTP.get_print('google.com', '/')