加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

从5a5x采集易语言源代码

发布时间:2020-12-17 04:10:01 所属栏目:百科 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 # encoding: ASCII-8BITrequire 'open-uri'def mastertitle = ["系统工具","图形图像","多媒体类","游戏娱乐","数据库类","模块控件","行业软件","网

以下代码由PHP站长网 52php.cn收集自互联网

现在PHP站长网小编把它分享给大家,仅供参考

# encoding: ASCII-8BIT
require 'open-uri'

def master
	title = ["系统工具","图形图像","多媒体类","游戏娱乐","数据库类","模块控件","行业软件","网络相关"]
	path = ["etools","eimage","emedia","egame","edata","ecom","etrade","enetwork"]
	Dir.mkdir("#{$run_file}/downfile") if !File.directory?("#{$run_file}/downfile")
	for i in 0..7
		Dir.mkdir("#{$run_file}/downfile/#{title[i]}") if !File.directory?("#{$run_file}/downfile/#{title[i]}")
		caiji(title[i],path[i])
	end
end

def caiji (title,path)
	url = "http://www.5a5x.com/wode_source/#{path}/"
	page_count = getCount "#{url}10.html"
	if page_count % 10 == 0
		page_count = page_count / 10
	else
		page_count = page_count / 10 + 1
	end

	for i in 1..page_count
		puts "正在处理#{title}第#{i}页,共#{page_count}页"
		html = open("#{url}#{i}.html").read
		a = 0
		while true
			a = html.index('<dt><a href="',a)
			break if a == nil
			a = a + 13
			b = html.index('"',a)
			download_page_url = html[a,b - a]
			a = b + 18
			b = html.index('<',a)
			file_title = html[a,b - a]
			download_url = getDownloadUrl download_page_url
			puts "正在下载:#{file_title}.zip"
			tmp = File.new("#{$run_file}/downfile/#{title}/#{file_title}.zip","w")
			tmp.binmode
			tmp.write open("http://www.5a5x.com/#{download_url}","r").read
			tmp.close
		end
	end
end

def getDownloadUrl download_page_url
	html = open("http://www.5a5x.com/#{download_page_url}").read
	a = html.index("<a href='down.php?a_k=") + 9
	b = html.index("'",a)
	url = html[a,b - a]
	html = open("http://www.5a5x.com/#{url}").read
	a = html.index('<a href="download.php?a_k=') + 9
	b = html.index('"',a)
	return html[a,b - a]
end

def getRunFile
	a = __FILE__.rindex "/"
	return __FILE__[0,a]
end

def getCount url
	html = open(url).read
	a = html.index("总数:<b>") + 9
	b = html.index("<",b - a].to_i
end
$run_file = getRunFile
master()

以上内容由PHP站长网【52php.cn】收集整理供大家参考研究

如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读