Class: Dumper::Profiles::YandeRe

Inherits:
Profile
  • Object
show all
Defined in:
lib/dumper/profiles/yande.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
# File 'lib/dumper/profiles/yande.rb', line 24

def dump(url, path, from, to)
  from.upto(to) { |i|
    notify_observers status: "--- Page #{i} ---"

    Nokogiri::HTML(open("#{url}&page=#{i}", 'User-Agent' => Dumper::USER_AGENT, 'Referer' => url)).xpath('//a[@class="thumb"]/@href').each { |p|
      @pool.process {
        img = Nokogiri::HTML(open('https://' + URI.parse(url).hostname + p,
          'User-Agent' => Dumper::USER_AGENT,
          'Referer'    => url
        )).at_xpath('//a[@id="png" or @id="highres"]/@href').text
        Dumper.get path, img, { referer: url }
      }
    }
  }
end