Created
June 2, 2015 17:32
-
-
Save takkumattsu/10ca0508e9f449e51940 to your computer and use it in GitHub Desktop.
http://killmebaby.tv/special_icon.html にあるキルミーベイベーのアイコンを取得し保存するスクリプト
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
require 'open-uri' | |
require 'nokogiri' | |
# Author:TakkuMattsu | |
# thanks: | |
# http://somethingpg.hatenablog.com/entry/20120603/1338715064 | |
# https://gist.github.com/ejo090/4480809f0a683255803e | |
# | |
url = 'http://killmebaby.tv/special_icon.html' | |
charset = nil | |
html = open(url) do |f| | |
charset = f.charset | |
f.read | |
end | |
page = Nokogiri::HTML.parse(html, nil, charset) | |
ary = Array.new | |
page.css('img').each do |link| | |
if /http:\/\/aka\.saintpillia\.com\/killme\/icon\/[0-9_-]{3,}\.png/ =~ link[:src] | |
ary.push(link[:src]) | |
end | |
end | |
ary.each_with_index do |url,index| | |
filename = "%04d.png"%index | |
dirname = Dir.pwd + "/" + filename | |
open(dirname, 'wb') do |file| | |
open(url) do |data| | |
file.write(data.read) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment