Class: Dumper::Profiles::MangaGo

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

def dump(url, path, from, to)
  n_pages = to > 1 ? to : Nokogiri::HTML(open(url)).at_xpath('//div[@class="page_select right"]/div[2]').text.scan(/\d+/).last.to_i

  from.upto(n_pages) { |i|
    @pool.process {
      page = Nokogiri::HTML open(url)

      url  = page.at_xpath('//a[@id="pic_container"]/@href').to_s
      scan = page.at_xpath('//img[@id="page1"]/@src').to_s[0..-3]

      Dumper.get path, scan, { referer: url, filename: "#{i}.#{scan.split(?.).last}" }
    }
  }
end