淘宝网防盗链图片批量下载

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

# == Synopsis
#
# Taobao tool all in one.
#
# == Author
# fujun
# 2011.06.01
#
# == Copyright
# Copyright (c) 2010 www.esoMei.cc Inc.
# All rights reserved.

STDOUT.sync = true; STDOUT.flush
STDERR.sync = true; STDERR.flush

require 'open-uri'

module Taobao
  class Tool
    def self.get(path, url)
      headers = {"Referer" => "http://mm.taobao.com/"}

      open(url, headers) do |fin|
        size = fin.size
        open(path, "wb") do |fout|
          while buf = fin.read(1024) do
            fout.write buf
            STDOUT.flush
          end
        end

        puts "[#{Time.now().to_s(:db)}] [OK] :url => #{url}, :size => #{size / 1024}KB."
      end
    end
  end
end