加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 taroxd 于 2016-1-4 10:23 编辑
我对这段代码是什么意思一无所知
require 'net/http' list = %W[ rpg_actor_mv rpg_actor_m rpg_actor_f rpg_actor_etc rpg_icon rpg_chadot4_10 rpg_chadot11_20 rpg_chadot21_30 rpg_chadot31_40 rpg_chadot41_50 rpg_chadot51_60 rpg_chadot61_70 rpg_chadot71_80 rpg_chadot81_90 rpg_chadot91_100 rpg_chadot101_110 rpg_chadot111_120 rpg_chadot121_130 rpg_chadot131_140 rpg_chadot141_150 rpg_chadot_etc rpg_window rpg_effect rpg_map ] list.each do |type| Net::HTTP.get('usui.moo.jp', "/#{type}.html").scan(/<img src=\"(.+?.png)\"/) do |(addr)| if addr.start_with? '.' addr = addr[1..-1] elsif !addr.start_with? '/' addr.prepend '/' end data = Net::HTTP.get('usui.moo.jp', addr) Dir.mkdir type unless Dir.exist? type File.open("#{type}/#{File.basename addr}", 'wb') { |f| f.write data } end end
require 'net/http'
list = %W[
rpg_actor_mv
rpg_actor_m
rpg_actor_f
rpg_actor_etc
rpg_icon
rpg_chadot4_10
rpg_chadot11_20
rpg_chadot21_30
rpg_chadot31_40
rpg_chadot41_50
rpg_chadot51_60
rpg_chadot61_70
rpg_chadot71_80
rpg_chadot81_90
rpg_chadot91_100
rpg_chadot101_110
rpg_chadot111_120
rpg_chadot121_130
rpg_chadot131_140
rpg_chadot141_150
rpg_chadot_etc
rpg_window
rpg_effect
rpg_map
]
list.each do |type|
Net::HTTP.get('usui.moo.jp', "/#{type}.html").scan(/<img src=\"(.+?.png)\"/) do |(addr)|
if addr.start_with? '.'
addr = addr[1..-1]
elsif !addr.start_with? '/'
addr.prepend '/'
end
data = Net::HTTP.get('usui.moo.jp', addr)
Dir.mkdir type unless Dir.exist? type
File.open("#{type}/#{File.basename addr}", 'wb') { |f| f.write data }
end
end
|