现在基于WEB页面的网络游戏越来越流行,由于是基于HTTP的,因此应该可以用LoadRunner来开发外挂。今天略为试了一下,证实是可行的。
以开心网的争车位游戏为例,用LoadRunner录制Web(HTTP/HTML)脚本,并进行适当的修改,主要是做一些关联和参数化。为速度起见,删掉一些资源请求的脚本。
脚本摘录如下:
Action()
{
char *parkID;
web_add_cookie("_uid=72750415; DOMAIN=www.kaixin001.com");
/* 访问开心网主页*/
web_url("www.kaixin001.com",
"URL=http://www.kaixin001.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
//"Url=http://img1.kaixin001.com.cn/i/n_bg_r.gif", ENDITEM,
//"Url=http://img1.kaixin001.com.cn/i/index_app.gif", ENDITEM,
LAST);
/*登录*/
web_submit_form("login.php",
"Snapshot=t2.inf",
ITEMDATA,
"Name=email", "Value=XXXX @126.com", ENDITEM,
"Name=password", "Value=XXXX", ENDITEM,
"Name=remember", "Value=<OFF>", ENDITEM,
EXTRARES,
// "Url=http://img1.kaixin001.com.cn/i/small-tri.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/r_sj.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/r_xx13.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/ddtx.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/account_set.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/pri_set.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/app_set.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/home/pay.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/ns_bg.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i2/xiasanjiao.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/index_app_add1.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/index_app_set1.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/dl_tsk.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/app_sprite_03.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/l120_s.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/home/hide_tips.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://s.kaixin001.com.cn/css/reg2.css", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
// "Url=http://img1.kaixin001.com.cn/i/inv/iv_nofbg.gif", "Referer=http://www.kaixin001.com/home/?uid=72750415", ENDITEM,
LAST);
/*此处,删掉一些脚本(为速度起见),如果是为了做压力测试则不要删除!*/
// ……
/*进入争车位游戏*/
// 这里要做一下关联,因为后面很多URL要使用“verify=”,相当于session id的作用
web_reg_save_param("verify_id",
"LB=var g_verify = /"",
"RB=/";",
LAST);
web_url("index.php",
"URL=http://www.kaixin001.com/!parking/index.php?t=43",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.kaixin001.com/home/?uid=72750415",
"Snapshot=t12.inf",
"Mode=HTML",
EXTRARES,
//"Url=http://img1.kaixin001.com.cn/i2/park/daoju.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://img1.kaixin001.com.cn/i2/park/sy.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://img1.kaixin001.com.cn/i2/park/cs.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://img1.kaixin001.com.cn/i2/park/ph.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=../swf/parking/parking-3.swf", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://img.kaixin001.com.cn/i/50_0_0.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://img1.kaixin001.com.cn/i2/park/ll.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://img1.kaixin001.com.cn/i2/park/help.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://img1.kaixin001.com.cn/i/l50_bg_s.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://img1.kaixin001.com.cn/i2/park/logo_alto.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://pic.kaixin001.com.cn/pic/car/0/0/2_1_7-16776960.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://img1.kaixin001.com.cn/i2/park/wdqc.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://img1.kaixin001.com.cn/i2/park/bar_off.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://img1.kaixin001.com.cn/i2/park/p2.gif", "Referer=http://www.kaixin001.com/!parking/index.php?t=43", ENDITEM,
//"Url=http://img.kaixin001.com.cn/i/20_0_0.gif", "Referer=http://www.kaixin001.com/swf/parking/parking-3.swf", ENDITEM,
//"Url=http://img1.kaixin001.com.cn/i2/scenes/bb2_1.jpg", "Referer=http://www.kaixin001.com/swf/parking/parking-3.swf", ENDITEM,
LAST);
lr_output_message(lr_eval_string("{verify_id}"));
web_submit_data("i.php",
"Action=http://www.kaixin001.com/interface/i.php",
"Method=POST",
"RecContentType=text/html",
"Referer=http://www.kaixin001.com/!parking/index.php?t=43",
"Snapshot=t13.inf",
"Mode=HTML",
ITEMDATA,
"Name=id", "Value=0", ENDITEM,
"Name=class", "Value=parking", ENDITEM,
EXTRARES,
"Url=http://img1.kaixin001.com.cn/i2/scenes/bb2_1.jpg", "Referer=http://www.kaixin001.com/swf/parking/parking-3.swf", ENDITEM,
LAST);
web_url("js_2",
"URL=http://m061156.kaixin001.com/ifr/js?r=http://s.kaixin001.com.cn/js/kxbase-1.js&r=http://s.kaixin001.com.cn/js/presence-12.js&rnd=0.2048821490060942",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.kaixin001.com/!parking/index.php?t=43",
"Snapshot=t14.inf",
"Mode=HTML",
EXTRARES,
"Url=../g/0.8747909947221656/72750415/ctx?_=1267005255776", "Referer=http://m061156.kaixin001.com/ifr/js?r=http://s.kaixin001.com.cn/js/kxbase-1.js&r=http://s.kaixin001.com.cn/js/presence-12.js&rnd=0.2048821490060942", ENDITEM,
"Url=../k/0.44502850747019995/72750415/2?_=1267005226418", "Referer=http://m061156.kaixin001.com/ifr/js?r=http://s.kaixin001.com.cn/js/kxbase-1.js&r=http://s.kaixin001.com.cn/js/presence-12.js&rnd=0.8299689421343095", ENDITEM,
LAST);
/*选择争车位对象*/
lr_save_string("1","Friend_ID");// 第几位
// 取到服务器返回的所有车位ID
web_reg_save_param("parkid",
"LB=parkid/":/"",
"RB=/",/"car_uid/":0,/"carid/":0,/"",
"ORD=All",
LAST);
web_submit_data("!neighbor.php",
"Action=http://www.kaixin001.com/!parking/!neighbor.php",
"Method=POST",
"RecContentType=text/html",
"Referer=http://www.kaixin001.com/!parking/index.php?t=43",
"Snapshot=t15.inf",
"Mode=HTML",
ITEMDATA,
"Name=verify", "Value={verify_id}", ENDITEM,
"Name=puid", "Value={Friend_ID}", ENDITEM,
EXTRARES,
"Url=http://img.kaixin001.com.cn/i2/park/f9.jpg", "Referer=http://www.kaixin001.com/swf/parking/parking-3.swf", ENDITEM,
"Url=http://pic.kaixin001.com.cn/pic/car/0/0/1_1_7-16776960.swf", "Referer=http://www.kaixin001.com/swf/parking/parking-3.swf", ENDITEM,
"Url=http://m061156.kaixin001.com/k/0.5935958843488411/72750415/2?_=1267005256713", "Referer=http://m061156.kaixin001.com/ifr/js?r=http://s.kaixin001.com.cn/js/kxbase-1.js&r=http://s.kaixin001.com.cn/js/presence-12.js&rnd=0.2048821490060942", ENDITEM,
LAST);
// 选择车
web_url("!selcar.php",
"URL=http://www.kaixin001.com/!parking/!selcar.php?verify={verify_id}",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.kaixin001.com/!parking/index.php?t=43",
"Snapshot=t31.inf",
"Mode=HTML",
LAST);
lr_output_message("选择第一个停车位:");
parkID = lr_paramarr_idx("parkid",1);
lr_output_message(parkID);
lr_save_string(parkID,"SelectedParkID");
/*确定提交*/
web_submit_data("!park.php",
"Action=http://www.kaixin001.com/!parking/!park.php",
"Method=POST",
"RecContentType=text/html",
"Referer=http://www.kaixin001.com/!parking/index.php?t=43",
"Snapshot=t32.inf",
"Mode=HTML",
ITEMDATA,
"Name=verify", "Value={verify_id}", ENDITEM,
"Name=park_uid", "Value={Friend_ID}", ENDITEM, /
"Name=parkid", "Value={SelectedParkID}", ENDITEM, // 选择停车位的ID
"Name=carid", "Value=65541", ENDITEM, // 自己车的ID
"Name=neighbor", "Value={Friend_ID}", ENDITEM,
"Name=acc", "Value=-goodness-a550", ENDITEM,
"Name=first_fee_parking", "Value=0", ENDITEM,
LAST);
web_submit_data("!neighbor.php_2",
"Action=http://www.kaixin001.com/!parking/!neighbor.php",
"Method=POST",
"RecContentType=text/html",
"Referer=http://www.kaixin001.com/!parking/index.php?t=43",
"Snapshot=t33.inf",
"Mode=HTML",
ITEMDATA,
"Name=verify", "Value={verify_id}", ENDITEM,
"Name=puid", "Value={Friend_ID}", ENDITEM,
EXTRARES,
"Url=http://pic.kaixin001.com.cn/pic/car/0/0/1_1_7-16776960.swf", "Referer=http://www.kaixin001.com/swf/parking/parking-3.swf", ENDITEM,
"Url=http://m061156.kaixin001.com/k/0.4103570536393127/72750415/2?_=1267009448290", "Referer=http://m061156.kaixin001.com/ifr/js?r=http://s.kaixin001.com.cn/js/kxbase-1.js&r=http://s.kaixin001.com.cn/js/presence-12.js&rnd=0.2276323110065261", ENDITEM,
LAST);
/*退出*/
web_url("logout.php",
"URL=http://www.kaixin001.com/login/logout.php",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.kaixin001.com/!parking/index.php?t=43",
"Snapshot=t16.inf",
"Mode=HTML",
LAST);
return 0;
}