Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Ruby equivalent of a simple Wget (See related posts)

Reads the file contents from a URL. I used this code to work around the problem with the Ruby RSS reader which couldn't read the RSS file from digg.com. The reason being that the website would not allow files to be downloaded without supplying the User-Agent string.

require 'open-uri'
puts open('http://digg.com/rss/index.xml',
     'User-Agent' => 'Ruby-Wget').read

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts