加急~~~~loadrunner如何获取网页图片~~~~请高手指点
现在公司有个任务,50个用户同时登陆一个地图网页,并能查看到这个地图的图片,并要保存这些图片到本地~注:每个用户登陆到这个网页,服务端会生成一个临时图片供用户查看,也就是说,50个用户同时登陆的时候,查看的是不同的图片。
录制源码如下,请高手赐教:
/*这个是域验证用户名和密码,登陆到网页
web_set_user("tgms\\{user}",
lr_decrypt("{pass}"),
"192.0.1.124:80");
/*请求的是这个URL
web_url("data.asp","URL=http://192.0.1.124/gisrct/data.asp?clientMapWidth=822&clientMapHeight=414",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"URL=images/TGMS.gif", "Referer=http://192.0.1.124/gisrct/data.asp?clientMapWidth=822&clientMapHeight=414", ENDITEM,
/*就是生成的这张图片名,要求保存到本地,最终50个用户取图片
"URL=http://webgissrv/output/SDEGIS_WEBGISSRV20362592484.png", "Referer=http://192.0.1.124/gisrct/data.asp?clientMapWidth=822&clientMapHeight=414", ENDITEM,
"URL=images/pixel.gif", "Referer=http://192.0.1.124/gisrct/data.asp?clientMapWidth=822&clientMapHeight=414", ENDITEM,
LAST);
急啊急,请高手赐教 没人回复。。。
不过已经找到解决方案了。发出来供大家学习
Action()
{
int iflen;
long ifbody;
//strncpy(tempstr2,strtmp,2);
//lr_output_message( tempstr2=%s,tempstr2);
lr_rendezvous("登陆");
lr_think_time(10);
web_set_user("tgms\\{user}",
lr_decrypt("{pass}"),
"192.0.1.124:80");
web_reg_save_param("imgURL" , "LB=src=\"" , "RB=\"" ,"Search=body", LAST);
web_reg_save_param ("fcontent" , "LB=" , "RB=" , "SEARCH=BODY" , LAST);
/* Request with GET method to URL "http://192.0.1.124/gisrct/data.asp?clientMapWidth=822&clientMapHeight=414" failed during recording. Server response : 401*/
web_url("data.asp",
"URL=http://192.0.1.124/gisrct/data.asp?clientMapWidth=822&clientMapHeight=414",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
EXTRARES,
"Url=images/TGMS.gif", "Referer=http://192.0.1.124/gisrct/data.asp?clientMapWidth=822&clientMapHeight=414", ENDITEM,
"URL={imgURL}", "Referer=http://192.0.1.124/gisrct/data.asp?clientMapWidth=822&clientMapHeight=414", ENDITEM,
"Url=images/pixel.gif", "Referer=http://192.0.1.124/gisrct/data.asp?clientMapWidth=822&clientMapHeight=414", ENDITEM,
LAST);
web_set_max_html_param_len("10000");
iflen =web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
lr_output_message("Start ");
if (iflen>0)
{
char filename = "c:\\";
char *tmpName = lr_eval_string("{imgURL}");
int i = strlen(tmpName);
char outputbuf={'\0'};
for(;i>=0;i--)
{
if( tmpName=='/')
{
break;
}
}
// i = strrchr(tmpName,'/');
// sprintf(outputbuf,"i = %d",i);
// lr_output_message(outputbuf);
strcat(filename,tmpName+i);
//strcat(filename,lr_eval_string("{imgURL}"));
lr_output_message(filename);
if ((ifbody=fopen (filename ,"wb"))==NULL)
{
lr_output_message("文件操作失败");
return - 1;
}
lr_output_message("Start Save file");
fwrite (lr_eval_string ("{fcontent}"),iflen , 1 , ifbody) ;
lr_output_message("Stop Save file");
fclose(ifbody);
}
if (iflen=0)
{
lr_output_message("length is 0");
} 很好。。。慢慢研究下。。。 看着有点显,没注释 代码太长,哪里修改了
页:
[1]