Project1

标题: 下载臼井素材用脚本 [打印本页]

作者: taroxd    时间: 2014-11-23 12:08
标题: 下载臼井素材用脚本
本帖最后由 taroxd 于 2016-5-1 16:25 编辑

RUBY 代码复制
  1. require 'net/http'
  2.  
  3. list = %W[
  4. rpg_actor_mv_m
  5. rpg_actor_mv_f
  6. rpg_actor_m
  7. rpg_actor_f
  8. rpg_actor_etc
  9. rpg_icon
  10. rpg_chadot4_10
  11. rpg_chadot11_20
  12. rpg_chadot21_30
  13. rpg_chadot31_40
  14. rpg_chadot41_50
  15. rpg_chadot51_60
  16. rpg_chadot61_70
  17. rpg_chadot71_80
  18. rpg_chadot81_90
  19. rpg_chadot91_100
  20. rpg_chadot101_110
  21. rpg_chadot111_120
  22. rpg_chadot121_130
  23. rpg_chadot131_140
  24. rpg_chadot141_150
  25. rpg_chadot_etc
  26. rpg_window
  27. rpg_effect
  28. rpg_map
  29. rpg_kinotake_sozai
  30. ]
  31.  
  32. def usui_scan_dl html, type, re
  33.   html.scan re do |(addr)|
  34.     addr.sub!(/\A(http:\/\/usui.moo.jp|\.)/, '')
  35.     addr.prepend '/' unless addr.start_with? '/'
  36.     data = Net::HTTP.get 'usui.moo.jp', addr
  37.     File.open("#{type}/#{File.basename addr}", 'wb') { |f| f.write data }
  38.     puts "Downloaded: #{addr}"
  39.   end
  40. end
  41.  
  42. list.each do |type|
  43.  
  44.   Dir.mkdir type unless Dir.exist? type
  45.  
  46.   html = Net::HTTP.get('usui.moo.jp', "/#{type}.html")
  47.   usui_scan_dl(html, type, /<img src=\"(.+?.png)\"/)
  48.   usui_scan_dl(html, type, /<a href=\"(.+?.zip)\"/)
  49. end





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1