QQ牧场快手 V20101006
http://www.ecranesoft.com/bbs/showtopic-9458.aspx
//QQ牧场快手
import win.ui;
import win.ole.image;
var qq,password; //QQ登录信息
var response; //最后一次网络请求的返回的数据
var urlOfMyPasture; //我的牧场URL
var urlOfFriendPastureList; //好友牧场列表URL
var sid; //SessionID
/*DSG{{*/
var winform = win.form(parent=...; text="QQ牧场快手 V20101006 by roking";bottom=470;max=false;right=343;border="thin" )
winform.add(
txtVerify={ disabled=1;bottom=76;right=238;left=138;top=52;font=LOGFONT( name="SimSun";h=-12 );z=10;text="";edge=1;cls="edit" };
txtQQ={ bottom=39;right=131;left=39;top=15;font=LOGFONT( name="SimSun";h=-12 );tabstop=1;z=2;text="";edge=1;cls="edit" };
txtDebug={ vscroll=1;text="";left=382;multiline=1;top=10;font=LOGFONT( name="SimSun";h=-12 );right=853;z=9;bottom=455;hscroll=1;edge=1;cls="edit" };
static={ right=80;bottom=40;text="QQ:";left=15;top=19;font=LOGFONT( name="SimSun";h=-12 );z=1;transparent=1;cls="static" };
static2={ right=210;bottom=38;text="密码:";left=142;top=20;font=LOGFONT( name="SimSun";h=-12 );z=3;transparent=1;cls="static" };
btnVerifyOK={ disabled=1;bottom=78;text="确定验证码";left=244;top=50;font=LOGFONT( name="SimSun";h=-12 );z=7;right=329;cls="button" };
lblLink={ bottom=459;color=16711680;text="使用快手(AAuto Quicker制作) 点这里获得程序源代码";left=12;top=446;font=LOGFONT( name="";h=-12 );z=11;notify=1;right=336;transparent=1;cls="static" };
lstInfo={ text="listbox";bgcolor=16777215;vscroll=1;right=332;left=11;
items={ };font=LOGFONT( name="SimSun";h=-12 );bottom=439;z=8;top=89;edge=1;cls="listbox" };
picVerify={ bgcolor=16777215;bottom=85;text="";border=1;top=45;font=LOGFONT( name="SimSun";h=-12 );z=6;right=134;left=34;transparent=1;cls="picturebox" };
btnLogin={ bottom=39;right=329;left=275;top=11;font=LOGFONT( name="SimSun";h=-12 );z=5;text="登录";cls="button" };
txtPwd={ bottom=38;right=265;left=173;top=14;font=LOGFONT( name="SimSun";h=-12 );text="";tabstop=1;password=1;z=4;edge=1;cls="edit" }
)
/*}}*/
/*显示消息*/
var msg = function(s){
winform.lstInfo.add(s);
winform.lstInfo.redraw();
::SendMessageInt(winform.lstInfo.hwnd,0x115/*_WM_VSCROLL*/,0x3/*_SB_PAGEDOWN*/,0);
}
/*发送http请求*/
var request = function(url,postdata=null){
import inet.http;
var http = inet.http("");
var data = http.down(url,postdata);
http.close();
data = string.fromto(data); //UTF8转换为ANSI编码
winform.txtDebug.text = "URL:" + url + '\r\n' + data;
winform.txtDebug.redraw();
response = data;
sid := string.match(response,'ontimer=\\".+\\?sid=([^\\"]+)');
}
/*取得效验码并等待输入*/
var getVerifyCode = function(){
import inet.http;
import fsys;
var url = string.match(response,'img src=\\"([^\\"]+)\\" alt=\\"验证码\\"');
var http = inet.http("");
var data = http.down(url);
http.close();
var tmpFile = fsys.getTempDir() + "\_verify.gif";
string.save(tmpFile,data);
winform.picVerify.image = tmpFile;
msg("请输入验证码!");
winform.txtVerify.text = "";
winform.txtVerify.disabled = 0;
winform.btnVerifyOK.disabled = 0;
}
/*进入我的牧场*/
var enterPasture = function(){
msg("正在进入我的牧场...");
var haveErr = false;
if(sid){
var url = (urlOfMyPasture)?urlOfMyPasture:"http://mc.z.qq.com/mc/main.jsp?sid=" ++ sid ++ "&B_UID=" ++ qq;
request(url);
try{
urlOfFriendPastureList = string.replace(string.match(response,'([^\\"]+)\\"\\>好友牧场\\<\\/a\\>'),"op=1","op=0");
urlOfFriendPastureList = string.replace(urlOfFriendPastureList,"&","&");
//成功进入牧场
winform.txtQQ.disabled = 1;
winform.txtPwd.disabled = 1;
winform.btnLogin.disabled = 1;
haveErr = false;
}
catch(e){
haveErr = true;
}
}
else {
haveErr = true;
}
if(haveErr){
//进入牧场失败
if(string.match(response,"密码错误")){
msg("QQ号码或密码错误!");
}
elseif(string.match(response,"验证码不正确")){
msg("验证码不正确!");
getVerifyCode();
}
else{
msg("DEBUG:进入我的牧场时发生错误!");
}
winform.txtQQ.disabled = 0;
winform.txtPwd.disabled = 0;
winform.btnLogin.disabled = 0;
}
return (!haveErr);
}
/*收获自己的产品*/
var gatherMyCrop = function(){
msg("------------- 收自己的产品 -------------");
var count = 0;
for s in string.gmatch( response,'([^\\"]+)\"\\>收获') {
count = count + 1;
if(count>=2){
url = string.replace(s,"&","&");
request(url);
}
}
msg("收获了:" + (count>=2?count-1:0) + "类产品");
}
/*偷好友的产品*/
var stealFriendCrop = function(){
msg("------------- 偷好友的产品 -------------");
//获得好友列表
request(urlOfFriendPastureList);
urlOfMyPasture := string.replace(string.match(response,'([^\\"]+)\\"\\>我的牧场\\<\\/a\\>'),"&","&");
var data = response;
var page = string.match(response,"共(\d+)页"); //好友列表分页
if(!page){
page = string.match(response,"第1/(\d+)页"); //另一种好友列表分页形式
}
if(page){
for(i=2;tonumber(page)){
var url = urlOfFriendPastureList ++ "&pageNo=" ++ i;
url = string.replace(url,"&","&");
request(url);
data =string.match(data,"\Z*") + response;
}
}
var pattern = '\\d{1,2}\\.\\<a\\shref=\\"([^\\"]+)\\"\\>([^\\<]+)\\<\\/a\\>';
var friendCount = 0; //好友计数
var gatheredFriendCount = 0; //收获的好友计数
//检查每个好友的牧场
for s,friend in string.gmatch(data,pattern) {
friendCount = friendCount + 1;
var url = s + "&a=1";
url = string.replace(url,"&","&");
request(url);
count = 0; //当前好友产品类数
for ss in string.gmatch(response,'([^\\"]+)\\"\\>收获\\<\\/a\\>') {
count = count + 1;
if(count>=2){
ss = string.replace(ss,"&","&");
request(ss);
}
}
if(count>0){
gatheredFriendCount = gatheredFriendCount + 1;
msg("光顾好友“" + friend + "”的牧场,收获 " + (count-1) + " 类产品");
}
else{
msg("光顾好友“" + friend + "”的牧场");
}
}
msg("共有 " + friendCount + " 个好友,收获了 " + gatheredFriendCount + " 个好友的产品");
}
/*收获*/
var gather = function(){
if(enterPasture()){ //如果进入牧场成功则收自己的产品
gatherMyCrop();
}
if(urlOfFriendPastureList){ //如果已经获得好友列表地址,则开始偷好友的产品
stealFriendCrop();
}
msg("------------- 本次任务结束 -------------");
var url = "http://qzone.z.qq.com/logout.jsp?sid=" + tostring(sid);
request(url);
msg("退出QQ登录");
msg("更多功能请下载源码自行修改:)");
urlOfMyPasture = null;
urlOfFriendPastureList = null;
winform.txtQQ.disabled = 0;
winform.txtPwd.disabled = 0;
winform.btnLogin.disabled = 0;
}
/*------------------------------ 窗体事件处理 --------------------------------*/
winform.btnVerifyOK.oncommand = function(id,event){
winform.txtVerify.disabled = 1;
winform.btnVerifyOK.disabled = 1;
var verify = winform.txtVerify.text;
var pattern = '\\<go href=\\"([^\\"]+)\\"[^\\<]+\\'
+ '<postfield name=\\"qq\\" value=[^\\<]+'
+ '\\<postfield name=\\"extend\\" value=\\"([^\\"]+)[^\\<]+'
+ '\\<postfield name=\\"r_sid\\" value=\\"(\\d+)[^\\<]+'
+ '\\<postfield name=\\"nb\\" value=\\"([^\\"]+)[^\\<]+'
+ '\\<postfield name=\\"modifySKey\\" value=\\"([^\\"]+)[^\\<]+'
+ '\\<postfield name=\\"verify\\"';
var s,extend,r_sid,nb,modifySKey = string.match(response,pattern) ;
extend = web.url.encode(extend) ;
extend = string.replace(extend,"@%2E",".");
var postdata = "qq=" + qq + "&"
+ "extend=" + extend + "&"
+ "r_sid=" + r_sid + "&"
+ "nb=" + nb + "&"
+ "modifySKey=" + modifySKey + "&"
+ "verify=" + verify;
request(s,postdata);
gather();
}
winform.btnLogin.oncommand = function(id,event){
winform.lstInfo.clear();
winform.lstInfo.redraw();
qq = winform.txtQQ.text;
password = winform.txtPwd.text;
sid = null;
request("http://qzone.z.qq.com/login.jsp");
var url,mkey = string.match(response,'([^\\"]+)\\" method=\\"post\\"\\>.+name=\\"mkey\\" value=\\"([^\\"]+)');
var postdata = "qq=" ++ qq ++ "&pwd=" ++ password + "&mkey=" + mkey;
request(url,postdata);
if(string.match(response,"@需要进行安全验证")){
getVerifyCode();
return;
}
gather();
}//endproc
winform.lblLink.oncommand = function(id,event){
import process;
process.execute("http://www.ecranesoft.com/");
}//endproc
//---------------------------------------------------------------------------------
winform.show()
win.loopMessage();
return winform;