Created
November 25, 2011 02:10
-
-
Save repeatedly/1392651 to your computer and use it in GitHub Desktop.
kita-colle girls downloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'optparse' | |
| require 'net/http' | |
| require 'date' | |
| def kg_download(path) | |
| uri = "http://www.kita-colle.com/i/mj/image/kg/kg_#{path}.jpg" | |
| res = Net::HTTP.get_response(URI.parse(uri)) | |
| if res.code.to_i == 200 | |
| filename = File.basename(uri) | |
| open(filename, 'wb') { |file| | |
| file.puts res.body | |
| } | |
| end | |
| end | |
| def to_kg_format(today) | |
| year, month, day = today.to_s.split('-') | |
| year = year[2..-1] | |
| path = year + month + day | |
| end | |
| # for cron | |
| $today_only = false | |
| OptionParser.new do |opt| | |
| opt.on('-t') { |v| $today_only = v } | |
| opt.parse!(ARGV) | |
| end | |
| end_day = Date.today | |
| if $today_only | |
| kg_download(to_kg_format(end_day)) | |
| else | |
| start_day = Date.new(2011, 8, 15) | |
| while start_day <= end_day | |
| kg_download(to_kg_format(start_day)) | |
| sleep 1 | |
| start_day += 1 | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment