115网盘自动续期工具 源码(支持分页)
115网盘不错,就是一直要续期,我们可以尝试着写个工具来替代我们的续期操作,要是加入自动启动项,那就更方便了。我写的这个只是实现了最简单的列文件、续期全部文件的功能,给大家作一个参考,大家可以自行扩展,体验 post 的魅力。
// 导入库
import inet.http;
import web.url;
// 配置登录信息
var account = "aautotest"; // 用户名
var passwd = "asd123"; // 密 码
io.open();
execute( "color F0" )
execute( "title 115 网盘自动续期工具 - Built by AAuto Quicker" );
try {
io.print( "正在登录 115..." );
var http = inet.http();
var data = http.down(
"http://my.115.com/?action=login",
"login[account]=" + web.url.encode(account) + "&" +
"login[passwd]=" + web.url.encode(passwd)
);
data = string.fromto( data );
var account2 = string.match( data, '([^\>]+)的账号' );
if( !account2 ) {
io.print( "登录失败,按下任意键结束" );
execute( "pause > nul" );
io.close();
} else {
io.print( account2 + " 登录成功,正在获取文件列表..." );
data = http.down( "http://u.115.com/?ct=my&ac=file" );
data = string.fromto( data );
var pageCount = string.match( data, "\<span\>共 (\d+) 页\</span\>" );
if( !pageCount ) {
pageCount = 1;
}
execute( "cls" );
io.print( '文件列表:\r\nID', "文件名" );
var tblFiles = {};
for (page = 1; pageCount; 1) {
data = http.down( "http://u.115.com/?ct=my&ac=file&s=" + 10 * (page - 1) );
data = string.fromto( data );
for( fileID, fileName in string.gmatch( data, "fileid='(\d+)' filename='([^']+)'" ) ) {
io.print( fileID, fileName );
table.push( tblFiles, fileID );
}
}
var result = "";
while( result != "Y" && result != "N" ) {
io.stdout.write( '\r\n是否进行全部续期(Y/N): ');
result = string.upper( io.stdin.read() );
}
if( result == "Y" ) {
var nCurrect = 0;
for( k, v in tblFiles ) {
execute( "cls" );
nCurrect++;
io.print( "正在续期第 " + nCurrect + " / " + #tblFiles + " 个文件..." );
http.down( "http://u.115.com/?ct=ajax&ac=renew_file&aid=1&cid=0&tid=" + v );
}
execute( "cls" );
io.print( "续期完毕,按任意键结束" );
execute( "pause > nul" );
}
io.print( "正在退出..." );
http.down( "http://my.115.com/?action=logout" );
io.close();
}
} catch( e ) {
io.print( "网络故障,请稍后再试" );
execute( "pause" );
io.close();
}
在115网盘的“我的文件”下,创建了多个子文件夹,列出子文件夹的文件,并进行续期
// 导入库
import inet.http;
import web.url;
// 配置登录信息
var account = "aautotest"; // 用户名
var passwd = "asd123"; // 密 码
io.open();
execute( "color F0" )
execute( "title 115 网盘自动续期工具 - Built by AAuto Quicker" );
try {
io.print( "正在登录 115..." );
var http = inet.http();
var data = http.down(
"http://my.115.com/?action=login",
"login[account]=" + web.url.encode(account) + "&" +
"login[passwd]=" + web.url.encode(passwd)
);
data = string.fromto( data );
var account2 = string.match( data, '([^\>]+)的账号' );
if( !account2 ) {
io.print( "登录失败,按下任意键结束" );
execute( "pause > nul" );
io.close();
} else {
io.print( account2 + " 登录成功,正在获取文件列表..." );
data = http.down( "http://u.115.com/?ct=my&ac=file&cid=866460" );
data = string.fromto( data );
var pageCount = string.match( data, "\<span\>共 (\d+) 页\</span\>" );
if( !pageCount ) {
pageCount = 1;
}
execute( "cls" );
io.print( '文件列表:\r\nID', "文件名" );
var tblFiles = {};
for (page = 1; pageCount; 1) {
data = http.down( "http://u.115.com/?ct=my&ac=file&cid=866460&s=" + 10 * (page - 1) );
data = string.fromto( data );
for( fileID, fileName in string.gmatch( data, "fileid='(\d+)' filename='([^']+)'" ) ) {
io.print( fileID, fileName );
table.push( tblFiles, fileID );
}
}
var result = "";
while( result != "Y" && result != "N" ) {
io.stdout.write( '\r\n是否进行全部续期(Y/N): ');
result = string.upper( io.stdin.read() );
}
if( result == "Y" ) {
var nCurrect = 0;
for( k, v in tblFiles ) {
execute( "cls" );
nCurrect++;
io.print( "正在续期第 " + nCurrect + " / " + #tblFiles + " 个文件..." );
http.down( "http://u.115.com/?ct=ajax&ac=renew_file&aid=1&cid=866460&tid=" + v );
}
execute( "cls" );
io.print( "续期完毕,按任意键结束" );
execute( "pause > nul" );
}
io.print( "正在退出..." );
http.down( "http://my.115.com/?action=logout" );
io.close();
}
} catch( e ) {
io.print( "网络故障,请稍后再试" );
execute( "pause" );
io.close();
}