Skip to content

Instantly share code, notes, and snippets.

@laguiar
Created June 2, 2009 22:44
Show Gist options
  • Save laguiar/122644 to your computer and use it in GitHub Desktop.
Save laguiar/122644 to your computer and use it in GitHub Desktop.
Get all images from a URL
require 'rubygems'
require 'hpricot'
require 'net/http'
require 'open-uri'
site = "http://www.globo.com"
html = Hpricot.XML(open(site))
images = html.search("//img").each do |img|
img_addr = img.get_attribute("src")
img_addr = site + img_addr if img_addr.slice(0..0) == "/"
puts `wget -q #{img_addr}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment