分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > IT知识

LR脚本示例之URL请求(post、get)

发布时间:2023-09-06 02:24责任编辑:沈小雨关键词:暂无标签

Action()
{
//application/x-www-form-urlencoded
//application/json
//web_add_auto_header("Content-Type","application/x-www-form-urlencoded");设置请求头信息

???//1、停顿2秒
???lr_think_time(2);

???//2、设置检查点
web_reg_find("SaveCount=count",
"Text=\"error_code\":0",
LAST);

//3、开始get请求
lr_start_transaction("get请求");

//4、提交get请求
???web_url("get请求",
???????????"URL=http://v.juhe.cn/laohuangli/d?date=2016-11-18&key=e711bc6362b3179f5a28de7fd3ee4ace",
???????????"TargetFrame=",
???????????"Resource=0",
???????????"RecContentType=text/html",
???????????"Referer=",
???????????"Snapshot=t7.inf",
???????????"Mode=HTML",
???????????LAST);

???//5、判断事物是否成功
???if(atoi(lr_eval_string("{count}")) > 0)
???{
???????//结束get请求
???????lr_end_transaction("get请求", LR_PASS);
???????lr_output_message("get请求=%s", lr_eval_string("{count}"));
???????lr_output_message("get请求成功");

???}
???else
???{
???????//结束get请求
???????lr_end_transaction("get请求", LR_FAIL);
???????lr_output_message("get请求失败");
???}

//1、停顿2秒
???lr_think_time(2);

//2、获取检查post请求的关联
web_reg_save_param("errorCode",
"LB=\"error_code\":",
"RB=\}",
LAST);

???//3、设置html支持的字符长度为1024
???web_set_max_html_param_len("1024");

???//4、开始post请求
???lr_start_transaction("post请求");

//5、提交post请求
???web_submit_data("post请求",
???????????????????"Action=http://v.juhe.cn/laohuangli/d",
???????????????????"Method=POST",
???????????????????"TargetFrame=",
???????????????????"RecContentType=application/json",
???????????????????"Referer=",
???????????????????"Snapshot=t12.inf",
???????????????????"Mode=HTML",
???????????????????ITEMDATA,
???????????????????"Name=date", "Value=2016-11-18", ENDITEM,
???????????????????"Name=key", "Value=e711bc6362b3179f5a28de7fd3ee4ace", ENDITEM,
???????????????????"Name=uri", "Value=", ENDITEM,
???????????????????LAST);


???//6、判断post请求事物是否成功
???if(atoi(lr_eval_string("{errorCode}"))==0)
???{
???????//结束post请求
???????lr_end_transaction("post请求", LR_PASS);
???????lr_output_message("post请求成功=%s", lr_eval_string("{errorCode}"));
???????lr_output_message("post请求成功");

???}
???else
???{
???????//结束post请求
???????lr_end_transaction("post请求", LR_FAIL);
???????lr_output_message("post请求失败");
???}


return 0;
}

LR脚本示例之URL请求(post、get)

原文地址:https://www.cnblogs.com/NiceTime/p/10025714.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved