OSDN Git Service

added sn_uploader
[tdcgexplorer/nimono-crawlers.git] / bin / mmdfile-idx.rb
1 #!/usr/bin/ruby
2 # download from mikumikudance
3 # http://loda.jp/mmdfile/
4
5 $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
6 require 'sn_uploader'
7
8 def each_filename(text)
9   text.scan(%r(<a href="(.+?)" >(.+?)</a>)) do |href, name |
10     yield name
11   end
12 end
13
14 uploader = SnUploader.new
15 uploader.host = "loda.jp"
16 uploader.root_path = "/mmdfile"
17 uploader.local_dir = '/Volumes/uploader/arc/mmdfile'
18   uploader.base_html = "/?page=1"
19   body = uploader.get_base
20   open('/Volumes/uploader/src/mmdfile/1.html', 'w') { |o| o.puts body }
21   each_filename(body) do |filename|
22     exist = uploader.local_file_exist?(filename)
23     puts [ filename, exist ? 'exist' : 'download' ].join("\t")
24     uploader.download_file_directly_id(filename)
25   end