下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
#!/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 }
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。