Ruby Programming/Standard Library/OpenURI

From Wikibooks, open books for an open world
< Ruby Programming
Jump to: navigation, search


OpenURI can be used to download a web page. Ex:

require 'open-uri'
   open("") {|f|
     f.each_line {|line| p line}

It appears to monkey patch the default "open" method for you, so that it is enhanced to take url's as well as its typical filenames etc.

See also Net::HTTP