字符串操作
1.字符串操作( 先strcpy 后strcat)
拷贝字符串到path路径下(从字符串前面开始操作)
*str= "aa.txt" strcpy( str ,"c:\top") ---c: opaa.txt
2.字符串链接函数
链接两个字符串 strcat (从字符串后面开始操作) strcat (str,str1)
3.将字符串转换为整形
atol(str) int i=0 char *s ="7 dollars" i =atol(s) lr_log_message("转换后的金额是 $%d" ,i)
4.字符串的拼接
sprintf() int index=56 char filename[56] , *suffix=''txt" sprintf(filename,"log_%d_%s",index,suffix) lr_message(filename)
二、日志输出函数
1.lr_output_message('sss') 输出日志 (存在网络传输、从负载机传到contouter) 2.lr_log_message('sssssss') 输出日志 (不存在网络传输、只打印在本机) 3.lr_message('sss') 4.lr_error_message('csssss') 错误输出 、打出的日志颜色红色高亮
三、时间 time
typedef long time_t; time_t t; lr_message ("Time in seconds since 1/1/70: %ld ", time(&t)); lr_message ("Formatted time and date: %s", ctime(&t));
四、协议相关函数
1. web_link web_url
非严格URL模式下出现
web_submit_data()
Referer 请求的来源
web_url("test.html", "URL=http://localhost/test.html", "Resource=0", "RecContentType=text/html", "Referer=", "Mode=HTML", LAST ); web_link("Test1", "Text=Test1", LAST );
2. 发送 post 请求的函数 web_submit_data 与 web_submit_form
web_submit_data 与 web_submit_form 后者是基于上下文的 有依赖关系 不能随意注释 web_submit_form 中的hidden 自动发送
3.web_custom_request 自定义http 请求
录制web -url -高级中的选项(web_custom_request)
4.web_add_header (key,value)
Adds the specified header to the next HTTP requests. web_add_header ('use","zhuifeng")
5. web_add_auto_header(key,value)
Adds the specified header to all subsequent HTTP requests
web_add_auto_header('use","zhuifeng")
6.获取响应的信息
web_get_int_propety(
HTTP_INFO_DOWNLOAD_SIZE
)
General Information 、HTTP_INFO_RETURN_CODE、HTTP_INFO_DOWNLOAD_SIZE、HTTP_INFO_DOWNLOAD_TIME
{ int HttpRetCode; web_url("my_home", "URL=http://my_home", "TargetFrame=_TOP", LAST ); HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE); if (HttpRetCode == 200) lr_log_message("The script successfully accessed the My_home home page"); else lr_log_message("The script failed to access the My_home home page "); }
Action() { int i; int j; lr_start_transaction("DownloadUrL"); web_url("club_registration.html", "URL=https://secure.funclubreg.com/funclub.com/registration_form.html", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", EXTRARES, "Url=images/inside/all_about_club.gif", ENDITEM, "Url=images/inside/whats_new.gif", ENDITEM, "Url=images/inside/club_news.gif", ENDITEM, "Url=images/inside/club_events_roll.gif", ENDITEM, "Url=findclubs.swf", ENDITEM, LAST ); /* Code the web_get_int_property function after the request (such as web_url or web_link) which starts the download. */ i = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE); lr_output_message("The download size of the URL was: %d",i); if(i > 10000) { lr_end_transaction("DownloadUrL", LR_PASS); } else { lr_end_transaction("DownloadUrL", LR_FAIL); } lr_start_transaction("DownloadPDF"); web_link("PDF version", "Text=PDF version", "Snapshot=t2.inf", LAST ); j = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE); lr_output_message("The download size of the PDF file was: %d",j); if(j > 10000) { lr_end_transaction("DownloadPDF", LR_PASS); } else { lr_end_transaction("DownloadPDF", LR_FAIL); } return 0; }