在机器D盘新建一个Excel的文件夹
Action()
{
long filedes;//保存文件句柄
int HttpRetCode;//返回http代码
int HttpRetTime;//返回页面下载时间
int HttpRetSize;//返回页面字节数
char file[256]="\0";//保存文件路径及文件名
char * strNumber; //定义一个随机数
strNumber=lr_eval_string("{RandomNum}");
strcat(file,"D:\\Excel\\"); //将路径保存到file变量中
strcat(file,strNumber); //将获得的随机数拼接在file变量之后
strcat(file,".txt"); //将下载的文件后缀名.txt拼接在file变量之后
/*web_reg_find("Fail=NotFound",
"Search=Body",
"SaveCount=success",
"Text=message",
LAST);*/
//并发开始
web_concurrent_start(NULL);
web_reg_save_param("fcontent",
"LB=",
"RB=",
"SEARCH=BODY",
LAST);
lr_start_transaction("tomcat");
web_url("DownLoadServlet",
"URL=http://xxx.xx.xxx/www/message",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);
//并发结束
web_concurrent_end(NULL);
/*HttpRetTime = web_get_int_property(HTTP_INFO_DOWNLOAD_TIME);
lr_output_message("The download time of the URL was: %d",HttpRetTime);*/
HttpRetSize = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
lr_output_message("The download size of the URL was: %d",HttpRetSize);
/*HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
if (HttpRetCode == 200){
lr_log_message("The Vuser successfully accessed the Dogbert home page");
}
else{
lr_log_message("The Vuser failed to access the Dogbert home page ");
}*/
if(HttpRetSize > 0)
{
//以写方式打开文件
if((filedes = fopen(file, "wb")) == NULL)
{
lr_output_message("open file failed!");
return -1;
}
//写入文件内容
fwrite(lr_eval_string("{fcontent}"), HttpRetSize, 1, filedes);
//关闭文件
fclose(filedes);
}
lr_end_transaction("tomcat", LR_AUTO);
return 0;
}

浙公网安备 33010602011771号