Fetch a URL in Ruby
require 'uri' require 'net/http' url = "http://www.whatever.com/whatever.txt" r = Net::HTTP.get_response(URI.parse(url).host, URI.parse(url).path)
r.code = 200 | 404 | 500, etc
r.body = *text of page*
DZone Snippets > peter > web
12389 users tagging and storing useful source code snippets
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
Peter Cooperx http://www.petercooper.co.uk/
require 'uri' require 'net/http' url = "http://www.whatever.com/whatever.txt" r = Net::HTTP.get_response(URI.parse(url).host, URI.parse(url).path)
curl -I http://www.google.com/