27ab6e535c3e5c93461af662708cf3d8

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.

#!/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 !

A49c247f0b25449a4b04e7a21dd9b97e

BC

February 5, 2009, February 05, 2009 00:11, permalink

1 rating. Login to rate!

Your refactoring





Format Copy from initial code

or Cancel