清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#!/usr/bin/env ruby
# > ruby1.9
# -*- coding: UTF-8 -*-
# qq flash 在线小游戏下载器
#
require 'rubygems'
require 'mechanize'
require 'pp'
#require 'win32/clipboard'
Url_base = 'http://game.kid.qq.com/'
Out_dir = 'G:\_flv_'
`md #{Out_dir}` unless Dir.exist? Out_dir
s_all = %Q{
http://game.kid.qq.com/static/article/11/38311.shtml
http://game.kid.qq.com/static/article/19/33519.shtml
http://game.kid.qq.com/static/article/87/38087.shtml
}
def get_it(x)
#p '2 getit ' + x.to_s
if x.class == Fixnum
x="http://game.kid.qq.com/static/article/#{x % 100}/#{"%05d" % x}.shtml"
end
if x !~ /^http/
if x =~ /\d{5}/
x=x.to_i
x="http://game.kid.qq.com/static/article/#{x % 100}/#{"%05d" % x}.shtml"
end
end
`title #{x} `
p '3 getit ' + x.to_s
mm = x.match(/\/\d\d\/\d{5}\.shtml/)[0]
url = Url_base + "static/article#{mm}"
r_url = Regexp.escape(url)
r = /<div class="StepLink">\s+<span>.+?<a href=".+?">.+?<\/a>><a href="\/">.+?<\/a>><\/span>(.+?)\s+<\/div>/
a = Mechanize.new
a.get url
b = a.page.body
if b.size < 3000
puts b
p b.size
sleep 1
return
end
#/static/article/14/40014.shtml
tmp = b.scan(/static\/article\/..\/(\d{5})\.shtml"/)
#pp tmp
#p ' tmp.size ' + tmp.size.to_s
$n = next_page = tmp.sample[0]
#p '4 next_page: ' + next_page
name =b.scan(r)[0][0].force_encoding('gbk')
if File.exist?(Out_dir + '/' + name+'.swf')
puts '5 file exist: ' + name
sleep 1
return
end
iMyGameId = b.scan(/var iMyGameId = "(.+?)";/)[0][0].to_i
u = "http:\/\/img.kid.qq.com\/fileupload\/flash\/#{"%02d" % (iMyGameId % 100)}\/#{iMyGameId}.swf"
p '6 url : ' + u
puts `wget #{u} -O #{Out_dir}/#{name}.swf` ; sleep 3
#p '7 np : ' + next_page
return next_page
end
s_all.each_line{|x|
next if x.chomp.empty?
get_it(x.chomp) }
i = 40014
100.times{
p '1 i: ' + i.to_s
get_it i
i = $n
sleep 0.2
}