下载AAuto开发环境(6.6MB 绿色不用安装 ),新建一个对话框工程,复制下面的代码到 main.aau 中点击生成EXE即可使用。
import win.ui; /*DSG{{*/ var winform = ..win.form( right=594;max=false;bottom=257;parent=...;text="CSDN 免积分下载工具( 有时候会下载失败,重试几次即可 )";border="dialog frame" ) winform.add( editUrl={ bottom=80;right=567;left=68;multiline=1;top=49;z=5;edge=1;cls="edit" }; btnPaste={ bottom=38;text="粘贴";left=400;top=9;z=3;right=458;cls="button" }; editSavePath={ bottom=213;right=374;left=68;multiline=1;top=183;z=8;edge=1;cls="edit" }; static={ bottom=40;align="right";right=65;left=8;top=19;transparent=1;text="资源网址:";z=2;cls="static" }; static2={ bottom=209;align="right";right=65;left=6;top=188;z=9;text="存储路径:";transparent=1;cls="static" }; editId={ right=394;bottom=39;text="http://download.csdn.net/detail/dba_huangzj/5321808";left=68;multiline=1;top=13;z=1;edge=1;cls="edit" }; btnGet={ bottom=38;text="转换为下载地址";left=464;top=9;z=4;right=566;cls="button" }; static3={ bottom=77;align="right";right=63;left=4;top=56;z=12;text="下载地址:";transparent=1;cls="static" }; btnDownload={ bottom=212;text="下载文件";left=384;top=182;z=6;right=472;cls="button" }; lbInfo={ bottom=207;right=568;left=482;top=190;transparent=1;z=11;cls="static" }; progress={ bottom=240;max=100;right=565;left=68;top=224;z=10;min=0;hide=1;edge=1;cls="progress" }; editDescription={ bottom=178;wrap=1;left=68;multiline=1;top=88;right=568;z=7;vscroll=1;edge=1;cls="richedit" } ) /*}}*/ import fsys; import web.rest.jsonClient; var downloadApi = web.rest.jsonClient().declareApi("http://download.csdn.net/index.php/rest/source/getsourceinfo/{0}","GET"); winform.btnGet.oncommand = function(id,event){ var id = string.match( winform.editId.text,"\d+$" ); if( !tonumber(id) ){ winform.msgboxErr("请输入下载ID") return; } var downInfo = downloadApi[ id ](); if( downInfo ){ winform.editDescription.text = downInfo.description; winform.editUrl.text = downInfo.url; winform.editSavePath.text = fsys.joinpath("/downlaod",downInfo.originfile) } } import win.clip; winform.btnPaste.oncommand = function(id,event){ winform.editId.text = win.clip.read() } import process; winform.btnDownload.oncommand = function(id,event){ var url = winform.editUrl.text; var savePath = winform.editSavePath.text; if( !( url && inet.url.is(url,0x0/*_URLIS_URL*/) ) ){ winform.btnGet.oncommand(); url = winform.editUrl.text; savePath = winform.editSavePath.text; if( !( url && inet.url.is(url,0x0/*_URLIS_URL*/) ) ){ winform.editUrl.text = "请先点击上面的获取下载网址按钮" return; } } winform.btnDownload.text = "下载中......" winform.btnDownload.disabled = true; var ok,err = win.invoke( function(url,savePath,hwndProgress,hwndInfo){ import fsys; import inet.whttp; import inet.httpFile; import win.ui; import win.ui.ctrl.progress; import win.ui.ctrl.static; var progress = win.ui.ctrl.progress() progress.hwnd = hwndProgress; var lbInfo = win.ui.ctrl.static() lbInfo.hwnd = hwndInfo; fsys.createParentDir(savePath) var remoteFile = inet.httpFile( url ,savePath ) remoteFile.onReciveBegin = function(statusCode,contentLength,fileSize){ progress.hide = false; progress.max = 1000; progress.pos = 0; progress.per = contentLength/1000; progress.downSize = fileSize; } remoteFile.onRecive = function(str,size,contentLength){ progress.downSize += size lbInfo.text = "已下载:" + fsys.formatSize(progress.downSize); progress.pos = progress.downSize/progress.per; } var ok,err; for(i=1;5;1){ lbInfo.text = "自动重试:" + i; ok,err = remoteFile.download(); if(ok) break; } progress.hide = true; return ok,err; },url,savePath,winform.progress.hwnd,winform.lbInfo.hwnd ) winform.btnDownload.text = "下载" winform.btnDownload.disabled = false; if( ok ){ process.explore_select(savePath) } else { winform.msgbox(err) } } winform.show() win.loopMessage();
原理 :其实就是 http://download.csdn.net/index.php/rest/source/getsourceinfo/+资源的ID就能看到下载的地址了