Class: Dumper::Profiles::Imagebam

Inherits:
Profile
  • Object
show all
Defined in:
lib/dumper/profiles/imagebam.rb

Instance Method Summary collapse

Instance Method Details

#dump(url, path, from, to) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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