Created
June 2, 2009 22:44
-
-
Save laguiar/122644 to your computer and use it in GitHub Desktop.
Get all images from a URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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