Jason Hsu, Android developer
2013-Feb-20 05:20 UTC
How do you download a file from the web and save it locally?
I''m trying to learn Ruby. A task I''m trying to do is download a file from the web and save it locally. I''m looking at http://ruby.bastardsbook.com/chapters/io/ and trying to implement the solution in the "Exercise: Copy Wikipedia''s front page to a file using block notation" section, but it''s not working for me. The error message I get is: /home/jhsu/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'': cannot load such file -- rest-client (LoadError) from /home/jhsu/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'' from test.rb:4:in `<main>'' What am I missing? Would another approach be better? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/p4raXgd9FK4J. For more options, visit https://groups.google.com/groups/opt_out.
Robert Walker
2013-Feb-20 06:37 UTC
Re: How do you download a file from the web and save it locally?
Jason Hsu, Android developer wrote in post #1097902:> I''m trying to learn Ruby. A task I''m trying to do is download a file > from > the web and save it locally. > > I''m looking at http://ruby.bastardsbook.com/chapters/io/ and trying to > implement the solution in the "Exercise: Copy Wikipedia''s front page to > a > file using block notation" section, but it''s not working for me. The > error > message I get is: > >/home/jhsu/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in> `require'': cannot load such file -- rest-client (LoadError) > from >/home/jhsu/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in> `require'' > from test.rb:4:in `<main>'' > > > What am I missing? Would another approach be better?Did you install the rest-client gem? gem install rest-client You you don''t have the gem installed Ruby can''t very well load it. Usually when you see that custom_require it assumes the name you gave in require statement is custom since it wasn''t found in the list of gems. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
tamouse mailing lists
2013-Feb-21 07:19 UTC
Re: How do you download a file from the web and save it locally?
On Tue, Feb 19, 2013 at 11:20 PM, Jason Hsu, Android developer <jhsu802701-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m trying to learn Ruby. A task I''m trying to do is download a file from > the web and save it locally. > > I''m looking at http://ruby.bastardsbook.com/chapters/io/ and trying to > implement the solution in the "Exercise: Copy Wikipedia''s front page to a > file using block notation" section, but it''s not working for me. The error > message I get is: > > /home/jhsu/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in > `require'': cannot load such file -- rest-client (LoadError) > from > /home/jhsu/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in > `require'' > from test.rb:4:in `<main>'' > > > What am I missing? Would another approach be better?Did you do this chapter first? http://ruby.bastardsbook.com/chapters/methods-and-gems/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Saravanan P
2013-Feb-21 11:30 UTC
Re: How do you download a file from the web and save it locally?
save_path="/your/local/path/filename" File.open(save_path, ''wb'') do |file| file << open(''download_file_url'').read end On Thu, Feb 21, 2013 at 2:19 AM, tamouse mailing lists < tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Feb 19, 2013 at 11:20 PM, Jason Hsu, Android developer > <jhsu802701-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''m trying to learn Ruby. A task I''m trying to do is download a file > from > > the web and save it locally. > > > > I''m looking at http://ruby.bastardsbook.com/chapters/io/ and trying to > > implement the solution in the "Exercise: Copy Wikipedia''s front page to a > > file using block notation" section, but it''s not working for me. The > error > > message I get is: > > > > > /home/jhsu/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in > > `require'': cannot load such file -- rest-client (LoadError) > > from > > > /home/jhsu/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in > > `require'' > > from test.rb:4:in `<main>'' > > > > > > What am I missing? Would another approach be better? > > > Did you do this chapter first? > http://ruby.bastardsbook.com/chapters/methods-and-gems/ > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Regards by Saravanan.P -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.