1、前程贷登录、投标脚本
Action()
{
// web_url("登录页",
// "URL=http://120.78.128.25:8765/Index/login.html",
// "TargetFrame=",
// "Resource=0",
// "Referer=",
// "Mode=HTML",
// LAST);
//
web_reg_save_param_ex(
"ParamName=get_login_result",
"LB=<p class="success">",
"RB=</p>",
"Ordinal=1",
SEARCH_FILTERS,
LAST);
lr_start_transaction("登录");
web_submit_data("login",
"Action=http://120.78.128.25:8765/Frontend/Index/login",
"Method=POST",
"TargetFrame=",
"Referer=",
"Mode=HTML",
ITEMDATA,
"Name=phone", "Value=13825161923", ENDITEM,
"Name=password", "Value=lemon123", ENDITEM,
"Name=remember_me", "Value=1", ENDITEM,
"Name=notify_url", "Value=", ENDITEM,
"Name=vcode", "Value=", ENDITEM,
LAST);
if(strcmp(lr_eval_string("{get_login_result}"),"登录成功")==0)
{
lr_end_transaction("登录", LR_PASS);
lr_output_message("登录结果:%s",lr_eval_string("{get_login_result}"));
}
else
{
lr_end_transaction("登录", LR_FAIL);
lr_error_message("登录结果:%s",lr_eval_string("{get_login_result}"));
}
web_reg_save_param_ex(
"ParamName=get_id",
"LB=href="/loan/loan_detail/Id/",
"RB=.html" class",
"Ordinal=1",
SEARCH_FILTERS,
LAST);
web_url("首页",
"URL=http://120.78.128.25:8765/Index/index",
"TargetFrame=",
"Resource=0",
"Referer=",
"Mode=HTML",
LAST);
web_reg_save_param_ex(
"ParamName=get_token",
"LB=" data-token="",
"RB=" data-id="",
"Ordinal=1",
SEARCH_FILTERS,
LAST);
web_url("投标页面",
"URL=http://120.78.128.25:8765/loan/loan_detail/Id/{get_id}.html",
"TargetFrame=",
"Resource=0",
"Referer=",
"Mode=HTML",
LAST);
web_reg_save_param_ex(
"ParamName=get_state",
"LB="state":",
"RB=,"msg":"",
"Ordinal=1",
SEARCH_FILTERS,
LAST);
lr_start_transaction("投标");
//
web_submit_data("投标",
"Action=http://120.78.128.25:8765/Invest/invest",
"Method=POST",
"TargetFrame=",
"Referer=",
"Mode=HTML",
ITEMDATA,
"Name=id", "Value={get_id}", ENDITEM,
"Name=val", "Value=200", ENDITEM,
"Name=token", "Value={get_token}", ENDITEM,
"Name=rewardValue", "Value=0", ENDITEM,
LAST);
if(strcmp(lr_eval_string("{get_state}"),"1")==0)
{
lr_end_transaction("投标", LR_PASS);
lr_output_message("投标成功,状态:%s",lr_eval_string("{get_state}"));
}
else
{
lr_end_transaction("投标", LR_FAIL);
lr_error_message("投标失败,状态:%s",lr_eval_string("{get_state}"));
}
return 0;
}
2、调试过程中,记得把日志从标准模式调成拓展模式;在runtimes settings里的General -〉 log
3、乱码处理:在runtime settings 里的preferences,点击options,找到General
4、总结(web_reg_save_param和web_reg_save_param_ex)区别
两者的功能差不多,但web_reg_save_param_ex功能更强大,可以截取获得字符串