1.strcpy使用
#include "web_api.h" Action() { int i = 0; char paramName[20]; char index[3]; // [WCSPARAM WCSParam_Diff1 42 101139.795220737fcAcDHipcVzzzzzHDVcVtpczQD] Parameter {WCSParam_Diff1} created by Correlation Studio web_reg_save_param( "WCSParam_Diff1", "LB=userSession value=", "RB=>", "Ord=1", "Search=Body", "RelFrameId=1.2.1", LAST ); web_url("MercuryWebTours", "URL=http://localhost/MercuryWebTours/", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", LAST); lr_think_time( 2 ); web_submit_data("login.pl", "Action=http://localhost/MercuryWebTours/login.pl", "Method=POST", "RecContentType=text/html", "Referer=http://localhost/MercuryWebTours/nav.pl?in=home", "Snapshot=t2.inf", "Mode=HTML", ITEMDATA, "Name=userSession", "Value={WCSParam_Diff1}", ENDITEM, "Name=username", "Value=jojo", ENDITEM, "Name=password", "Value=bean", ENDITEM, "Name=JSFormSubmit", "Value=on", ENDITEM, "Name=login.x", "Value=48", ENDITEM, "Name=login.y", "Value=9", ENDITEM, LAST); web_reg_save_param("FlightID", "LB=NAME="flightID" VALUE="", "RB=">", "ORD=ALL", "SEARCH=BODY", LAST); web_image("Itinerary Button", "Alt=Itinerary Button", "Snapshot=t3.inf", LAST); for(i=1; i<=atoi(lr_eval_string("{FlightID_count}")); i++) { strcpy(paramName, "{FlightID_"); itoa(i,index,10); lr_output_message("index=%s", index); strcat(paramName, index); strcat(paramName, "}"); lr_output_message("Parameter %s = %s", paramName, lr_eval_string(paramName)); } lr_think_time( 2 ); web_image("SignOff Button", "Alt=SignOff Button", "Ordinal=1", "Snapshot=t5.inf", LAST); return 0; }
2.download&long&fp
#include "web_api.h" Action() { long fp; web_url("download.html", "URL=http://localhost/download.html", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", LAST); web_reg_save_param("Content", "LB=", "RB=", "SEARCH=BODY", LAST); web_link("click to download sample.zip", "Text=click to download sample.zip", LAST); fp = fopen("c:\sample.zip", "wb"); if(fp == 0) { lr_output_message("Open file error "); return -1; } fwrite(lr_eval_string("{Content}"), web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE), 1, fp); fclose(fp); return 0; }
3.download&long&fp2
Action() { long fp; unsigned long filelen; char *fcontent; web_add_cookie("AJSTAT_ok_pages=9; DOMAIN=www.guanheshan.com"); web_add_cookie("AJSTAT_ok_times=1; DOMAIN=www.guanheshan.com"); web_reg_save_param("filecontent", "LB=", "RB=", "SEARCH=BODY", LAST); web_url("sample.tar.gz", "URL=http://www.guanheshan.com/sample.tar.gz", "Resource=1", "RecContentType=application/x-gzip", "Referer=", "Snapshot=t1.inf", LAST); //filelen = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE); lr_eval_string_ext("{filecontent}", strlen("{filecontent}"), &fcontent, &filelen, 0, 0, -1); fp = fopen("E:\sample.tar.gz", "wb"); //fwrite(lr_eval_string("{filecontent}"), filelen, 1, fp); fwrite(fcontent, filelen, 1, fp); fclose(fp); return 0; }
4.lr_load_dll使用
#include "web_api.h" Action() { int rc, re; rc = lr_load_dll("parameterdll.dll"); if(rc != 0) { return -1; } re = add2int(1,3); lr_output_message("Call function add2int result: %d", re); return 0; }
5.lr_load_dll2
#include "web_api.h" Action() { int rc; int max, min; rc = lr_load_dll("lrdll.dll"); if(rc) { lr_output_message("Error in loading dll "); return -1; } max = Max(2, 4, 6); min = Min(5, 3, 4); lr_output_message("Max is %d, Min is %d", max, min); lr_load_dll("c:\windows\system32\user32.dll"); MessageBoxA(0, "This is a sample", "Test", 0); return 0; }