import win.ui;
import web.mshtml
mainForm = ..win.form(text="AAuto工程3";right=176;bottom=99)
mainForm.add(button={cls="button";text="分析地址";left=30;top=30;right=130;bottom=70;z=1})
//采集指定块的小说地址
var ids = {1;2;3;4;5;6;7;8;9}
mainForm.button.oncommand = function(id,event){
//定义hash表,存储下载地址
tdist := {};
//获取源码
http = web.mshtml();
http.document.designMode = "on"
http.go("http://www.sxcnw.net/topjs.html")
//获取列表块
eles = http.queryEles( className = "ranks_box green_box")
for(i=1;#ids){
//通过正则获取a标签内容
for m in string.gmatch(eles[ids[i]].innerhtml,'href="(.*?)"') {
//屏蔽更多的链接
s,e = string.indexOf(m,".html")
if( s )
continue ;
//将a标签内容存起来,进行重复过滤
var key = m
if( not tdist[key]){
tdist[key] = "http://www.sxcnw.net" + m
}
}
}
//将最后分析结果放到d盘下
file = io.open("d:/urls.txt","w")
for(k,v in tdist)
file.write(downloadurl(v)+'
')
file.close()
mainForm.msgbox("处理完毕")
}
//根据之前a标签地址,分析出真实下载地址
//不知道怎么回事,只能通过迅雷下载,不过不影响我最终使用,就先这样了
downloadurl = function(url){
http = web.mshtml();
http.document.designMode = "on"
http.go(url)
eles = http.queryEles(className = "thelinks")
downurl = "http://www.sxcnw.net/"+string.match(eles[2].innerhtml,'href="(.*?)"')
downurl = string.replace(downurl,"amp;","")
http.go(downurl)
eles = http.queryEles(className="flash")
downurl = string.match(eles.innerhtml,'href="(.*?)"')
return downurl;
}
mainForm.show()
win.loopMessage();