lr--atoi、itoa

Action()
{
int pageSum; //存总共的页数
char randpage[4];//存随机后的页数

//访问首页的事务
lr_start_transaction("homePage");

web_url("e6mall",
"URL=http://192.168.1.101:40001/e6mall/",
LAST);
lr_end_transaction("homePage",LR_AUTO);

//取得总共的页数
web_reg_save_param("page",
"LB=href=\"?c=browse&keyword=&cg=&marker=B&page=",
"RB=\">鏈€鍚庨〉</a></span> ",
LAST);

web_url("e6mall",
"URL=http://192.168.1.101:40001/e6mall/?c=browse",
LAST);

//取到总分页数,在此范围内随机取值

pageSum=atoi(lr_eval_string("{page}"));
//lr_output_message("%d",pageSum);
//lr_output_message("randpage %d",rand()%pageSum+1);
itoa(rand()%pageSum+1,randpage,10); //在pageSum范围取随机,使用itoa以10进制方式转换成string保存到randpage中
lr_save_string(randpage,"rpage");//把string格式的分页数,保存到rpage

lr_start_transaction("page");

web_url("e6mall",
"URL=http://192.168.1.101:40001/e6mall/?c=browse&keyword=&cg=&marker=B&page={rpage}",
LAST);

lr_end_transaction("page",LR_AUTO);
return 0;
}

posted @ 2015-03-02 14:44  hotarubi  阅读(380)  评论(0编辑  收藏  举报