LR-下载并保存文件到本地

上一篇 / 下一篇  2009-01-09 10:03:29 / 个人分类:LoadRunner

#include "web_api.h"
Action()
{
    int iflen; //文件大小
 long lfbody;  //响应数据内容大小   
 web_set_max_html_param_len("10000");

    //将响应信息存放到fcontent变量
    web_reg_save_param("fcontent","LB=","RB=","SEARCH=BODY",LAST);

 web_url("下载rar",
 "URL=http://www.baidu.com/img/baidu_logo.gif",
 "Resource=0",
 "RecContentType=application/xml",
 "Referer=http://www.baidu.com",
 "Snapshot=t9.inf",
 "Mode=HTML",
 LAST);

    //获取响应大小
    iflen = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
 if(iflen > 0)
 {
  //以写方式打开文件
  if((lfbody = fopen("e:\\abc.gif", "wb")) == NULL)
  {
   lr_output_message("文件操作失败!");
   return -1;
  }
  //写入文件内容
  fwrite(lr_eval_string("{fcontent}"), iflen, 1, lfbody);
  //关闭文件
  fclose(lfbody);
 }
 return 0;
}


TAG: loadrunner

 

评分:0

我来说两句

Open Toolbar