Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
http://killmebaby.tv/special_icon.html にあるキルミーベイベーのアイコンを取得し保存するスクリプト
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
You can’t perform that action at this time.