From: Davi Vidal Date: 2009-01-15T01:58:34+09:00 Subject: Re: Downloading an MP3 from the internet -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Nathaniel Escribano wrote: [...] >> Here is an alternative way of doing it: >> >> require 'open-uri' >> open("http://cdn.stereogum.com/mp3/My Morning Jacket - Celebration >> (Live).mp3") do |src| >> open("Celebration.mp3","wb") do |dst| >> while blk = src.read(65536) >> dst.write(blk) >> end >> end >> end >> [...] My $ 0.02: require 'open-uri' require 'cgi' url = 'http://cdn.stereogum.com/mp3/' + CGI::escape('My Morning Jacket - Celebration (Live).mp3') open(url) do |src| open('Celebration.mp3', 'wb') do |dst| while blk = src.read(65536) dst.write(blk) end end end hth, davi -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkluE4MACgkQ76Bs0E5RGKNDnQCgnL2MY93V0uAhc1dQGV1cTP09 NaEAoKFroaj3pxGPrjf9u2CUzKV2gFAK =/OkJ -----END PGP SIGNATURE-----