class Dumper::Profiles::Imagebam

Public Instance Methods

dump(url, path, from, to) click to toggle source
# File lib/dumper/profiles/imagebam.rb, line 24
def dump(url, path, from, to)
    from -= 1
    to   -= 1 if to >= 1

    [].tap { |urls|
      Nokogiri::HTML(open(url)).xpath('//a[@style="border:none; margin:2px;"]/@href').each { |u|
        urls << u if u.to_s.start_with? 'http://www.imagebam.com/image/'
      }
    }[from..to].each { |p|
      Nokogiri::HTML(open(p)).xpath('//img[@onclick="scale(this);"]/@src').each { |u|
        @pool.process {
          Dumper.get path, u
        }
      }
    }
end