fork download
  1. require"open-uri"
  2. require"kconv"
  3. require"mechanize"
  4.  
  5.  
  6. #v = "http://w...content-available-to-author-only...o.jp/gp/product/images/4089081661/"
  7. #v = "http://w...content-available-to-author-only...o.jp/gp/product/images/4757536356/ref=dp_image_z_0?ie=UTF8&n=465392&s=books"
  8. v = "http://w...content-available-to-author-only...o.jp/gp/product/images/4799202170/"
  9. #v =~ /images\/(\d*)\//
  10. v =~ /[product|images]\/(\d*)\//
  11. vi = p $1
  12.  
  13. agent = Mechanize.new
  14. agent.user_agent_alias = "Windows IE 7"
  15.  
  16. uri = URI.parse( v )
  17.  
  18. agent.get(uri)
  19.  
  20. a=agent.page.body.each_line.each do |m|
  21. if m =~ /addZoomViewer/
  22. puts m
  23. break m
  24. end
  25. end
  26.  
  27. a =~ /(\d*),"amztile"/
  28. ai = p $1
  29.  
  30. files = []
  31. b=6.times.map do | i |
  32. 6.times.map do | k |
  33. s = "http://z...content-available-to-author-only...n.com/R/1/a=#{vi}+d=_SCR%283,#{i},#{k}%29_+o=01+s=RMTILE+va=MAIN+ve=#{ai}+e=.jpg"
  34. file = "_t_#{k}_#{i}.jpg"
  35. begin
  36. f = open(s,"rb").read
  37. open( file ,"wb").print f
  38. files << file
  39. rescue
  40. # p "file_none_ #{ s }"
  41. end
  42. end
  43. end.flatten.compact
  44.  
  45.  
  46. #b.each do |m|
  47. # m.chomp!
  48. # puts "<img src=\"#{m}\">"
  49. #end
  50.  
  51.  
  52.  
  53. def func ar , name , append
  54. ar.inject do | a , b |
  55. pt = "__pt_#{name}.jpg"
  56. if append == :+
  57. `"C:\\Program Files\\ImageMagick-6.5.6-Q8\\convert" +append #{a} #{b} #{pt}`
  58. elsif append == :-
  59. `"C:\\Program Files\\ImageMagick-6.5.6-Q8\\convert" -append #{a} #{b} #{pt}`
  60. else
  61. p :err
  62. exit
  63. end
  64. pt
  65. end # inject
  66. end
  67.  
  68.  
  69. p files.sort
  70.  
  71. sl = files.sort.map do |m|
  72. m =~ /(\d*).jpg/
  73. $1
  74. end.max.to_i + 1
  75.  
  76. gg = files.sort.each_slice( sl ).each_with_index.map do |m , i|
  77. p m
  78. func m , i , :+
  79. end
  80. func gg , "_kuu_mazo____" , :-
  81.  
  82. [files+gg].flatten.each do |m|
  83. File.unlink m
  84. end
  85.  
  86.  
  87.  
Runtime error #stdin #stdout 0.09s 7244KB
stdin
Standard input is empty
stdout
Standard output is empty