Martian eyrie

February 6, 2007

Ruby module: OpenURI (open-uri.rb)

Filed under: RubyOnRails

open-uri: Ruby Standard Library Documentation

 It is possible to open http/https/ftp URL as usual like opening a file:
	
   open("http://www.ruby-lang.org/") {|f|     f.each_line {|line| p line}   }
	
 The opened file has several methods for meta information as follows since it is extended by OpenURI::Meta.
	
   open("http://www.ruby-lang.org/en") {|f|     f.each_line {|line| p line}     p f.base_uri         # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>     p f.content_type     # "text/html"     p f.charset          # "iso-8859-1"     p f.content_encoding # []     p f.last_modified    # Thu Dec 05 02:45:02 UTC 2002   }

Comments »

The URI to TrackBack this entry is: http://eyrie.blogsome.com/2007/02/06/ruby-module-openuri-open-urirb/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.






















Get free blog up and running in minutes with Blogsome
Theme designed by Minz Meyer