#!/usr/bin/ruby
require 'rubygems'
require 'open-uri'
require 'hpricot'
print 'Digite o nome do arquivo local: '
local_file_name = STDIN.gets.chomp
doc = open(ARGV[0]) { |file| Hpricot(file) }
img_url = ''
doc.search("//div[@class='photoImgDiv']") do |div|
div.search("//img[@class='reflect']") do |img|
img_url = img.attributes['src']
end
end
File.open(local_file_name, "wb").write(open(img_url).read)
Refactorings
No refactoring yet !
BC
February 5, 2009, February 05, 2009 00:11, permalink
Why not use the API: http://www.flickr.com/services/api/
With a ruby client: http://rubyforge.org/projects/flickr/
Hello this is my first post here. I'm still learning Ruby and I need to know if there are another diferent forms to do that.