<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: net-http code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 06 Oct 2008 16:00:11 GMT</pubDate>
    <description>DZone Snippets: net-http code</description>
    <item>
      <title>How to download files with Ruby</title>
      <link>http://snippets.dzone.com/posts/show/2469</link>
      <description>// Note: the "b" in "wb" in the open method may not be needed in&lt;br /&gt;// non-Windows environments.  In Windows it indicates that you're writing&lt;br /&gt;// binary information.  You probably won't need it for downloading straight text&lt;br /&gt;// or html either.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'net/http'&lt;br /&gt;&lt;br /&gt;Net::HTTP.start("static.flickr.com") { |http|&lt;br /&gt;  resp = http.get("/92/218926700_ecedc5fef7_o.jpg")&lt;br /&gt;  open("fun.jpg", "wb") { |file|&lt;br /&gt;    file.write(resp.body)&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;puts "Yay!!"&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 25 Aug 2006 19:59:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2469</guid>
      <author>TDonaghe (Terry Donaghe)</author>
    </item>
  </channel>
</rss>
