require"open-uri"
require"kconv"
require"mechanize"
#v = "http://w...content-available-to-author-only...o.jp/gp/product/images/4089081661/"
#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"
v = "http://w...content-available-to-author-only...o.jp/gp/product/images/4799202170/"
#v =~ /images\/(\d*)\//
v =~ /[product|images]\/(\d*)\//
vi = p $1
agent = Mechanize.new
agent.user_agent_alias = "Windows IE 7"
uri = URI.parse( v )
agent.get(uri)
a=agent.page.body.each_line.each do |m|
if m =~ /addZoomViewer/
puts m
break m
end
end
a =~ /(\d*),"amztile"/
ai = p $1
files = []
b=6.times.map do | i |
6.times.map do | k |
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"
file = "_t_#{k}_#{i}.jpg"
begin
f = open(s,"rb").read
open( file ,"wb").print f
files << file
rescue
# p "file_none_ #{ s }"
end
end
end.flatten.compact
#b.each do |m|
# m.chomp!
# puts "<img src=\"#{m}\">"
#end
def func ar , name , append
ar.inject do | a , b |
pt = "__pt_#{name}.jpg"
if append == :+
`"C:\\Program Files\\ImageMagick-6.5.6-Q8\\convert" +append #{a} #{b} #{pt}`
elsif append == :-
`"C:\\Program Files\\ImageMagick-6.5.6-Q8\\convert" -append #{a} #{b} #{pt}`
else
p :err
exit
end
pt
end # inject
end
p files.sort
sl = files.sort.map do |m|
m =~ /(\d*).jpg/
$1
end.max.to_i + 1
gg = files.sort.each_slice( sl ).each_with_index.map do |m , i|
p m
func m , i , :+
end
func gg , "_kuu_mazo____" , :-
[files+gg].flatten.each do |m|
File.unlink m
end
cmVxdWlyZSJvcGVuLXVyaSIKcmVxdWlyZSJrY29udiIKcmVxdWlyZSJtZWNoYW5pemUiCgoKI3YgID0gImh0dHA6Ly93Li4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5vLmpwL2dwL3Byb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