Class: Ishuhui::IshuhuiComic

Inherits:
Thor
  • Object
show all
Defined in:
lib/ishuhui.rb

Constant Summary collapse

ISHUHUI_URL =
"http://www.ishuhui.com/"

Instance Method Summary collapse

Instance Method Details

#download(url) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ishuhui.rb', line 12

def download (url)
  @page = parse_page(url)
  @title = @page.css("hgroup h1").text.to_s
  create_folder("ishuhui")
  Dir.chdir("ishuhui")
  create_folder(@title)
  imgs = @page.css("div.article-content img")
  imgs.each_with_index do |img, i|
    puts "downloading #{i + 1}/#{imgs.count}"
    download_img(img[:src])
  end
  puts "all done in the folder below:\n ./ishuhui/#{@title}"
end