class Dumper::Profiles::YandeRe

Public Instance Methods

dump(url, path, from, to) click to toggle source
# 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