Created
February 8, 2014 16:01
-
-
Save sota1235/8885899 to your computer and use it in GitHub Desktop.
This file contains 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
#! /usr/bin/ruby | |
# Date 2014/02/08 | |
# Created by sota1235 | |
require 'open-uri' | |
# 成功したら配列から削除 | |
$array = [*1..1368] | |
def save_pic(url) | |
fName = File.basename(url) | |
# ファイル保存場所 | |
path = "/hoge/" + fName | |
begin | |
open(path,'wb') do |output| | |
open(url) do |data| | |
output.write(data.read) | |
end | |
end | |
print(fName," is success.\n") | |
$array.delete(fName.delete(".png").to_i) | |
$array.insert fName.delete(".png").to_i - 1, "x" # xを突っ込むことでfor文でのポインタずれを回避 | |
rescue | |
print(fName," is failed.\n") | |
File.unlink path | |
end | |
end | |
base1 = "http://hoge-" | |
base2 = "-moge/" | |
for num1 in 48..57 do | |
for num2 in $array do | |
unless num2=='x' | |
save_pic(base1 + num1.to_s + base2 + num2.to_s + ".png") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment