daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require "net/http"
  2.  
  3. $host_ip   = "255.255.255.0"
  4. $directory = "/h/f/p/g/"
  5. $extension = ".jpg"
  6.  
  7. # サーバへの気持ち
  8. $wait_time = 0.5
  9.  
  10. $type = (1..3).to_a
  11. $rank = (0..5).to_a
  12. $num  = (1..100).to_a
  13.  
  14. def is_rank_plus? rank
  15.   return rank%2 == 1
  16. end
  17.  
  18. # RETURN: File Exists?
  19. def save_file file
  20.   data = Net::HTTP.get $host_ip, ( $directory + file )
  21.   p "http request :#{file}"
  22.   return false if data =~ /Not Found/
  23.     f = open file, "w"
  24.   f.write data
  25.   f.close
  26.   p "save :#{file}"
  27.   return true
  28. end
  29.  
  30. def get_character_cards type, rank, number, diffs
  31.   diffs.each do |d|
  32.     file = ( sprintf "%d%d%03d%02d%s", type, rank, number, d, $extension )
  33.     next if FileTest.exists? file
  34.     break unless save_file file
  35.   end
  36. end
  37.  
  38. # 欠番
  39. f = open "3302002.jpg", "w"
  40. f.close
  41.  
  42. # main
  43. $type.each do |t|
  44.   $rank.each do |r|
  45.     $num.each do |n|
  46.       next if Dir::glob( sprintf "%d%d%03d*%s", t, r, n, $extension ).any?
  47.       sleep $wait_time
  48.       if is_rank_plus? r
  49.         get_character_cards t, r, n, [2]
  50.         get_character_cards t, r, n, [5, 6, 7, 8, 9]
  51.         get_character_cards t, r, n, [11]
  52.       else
  53.         get_character_cards t, r, n, [1, 2, 3, 4]
  54.         get_character_cards t, r, n, [10]
  55.       end
  56.       break unless Dir::glob( sprintf "%d%d%03d*%s", t, r, n, $extension ).any?
  57.     end
  58.   end
  59. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top