LR-

xiaoxiao2025-11-16  5

#define RECEIVE_DAY 3 Action2() { char * url = "http://127.0.0.1:1080/WebTours/"; char *URL = (char *)malloc(1024*sizeof(char)); char * departure_city, *arrive_city, *departDate, *returnDate; int result,flag; int rd_num,i; char *seatPref, *seatType; int amount[100]; char *code_ticket; sprintf(URL, "URL=%s",url); lr_save_string(URL,"base_url"); // lr_output_message(">>>>>>>>>>>> %s", URL); // lr_output_message(">>>>>>>>>>>> %s", lr_eval_string("{base_url}")); web_set_max_html_param_len("1024"); web_reg_save_param("userSession", "LB=userSession value=", "RB=>", "Ord=1", "Search=Body", // "LB/IC=userSession value=", // "RB/IC=>", // "Ord=1", // "Search=Body", // "RelFrameId=1.2.1", LAST); /*open web*/ web_url("WebTours", URL, "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t23.inf", "Mode=HTML", LAST); lr_think_time(8); // lr_output_message(">>>>>> userSession = %s",lr_eval_string("{userSession}")); // lr_output_message("%s",lr_eval_string("{userSession}")); web_reg_find("Text=Welcome, <b>jojo", LAST); web_submit_data("login.pl", "Action=http://127.0.0.1:1080/WebTours/login.pl", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home", "Snapshot=t24.inf", "Mode=HTML", ITEMDATA, "Name=userSession", "Value={userSession}", ENDITEM, "Name=username", "Value={username}", ENDITEM, "Name=password", "Value={passwd}", ENDITEM, "Name=JSFormSubmit", "Value=on", ENDITEM, "Name=login.x", "Value=48", ENDITEM, "Name=login.y", "Value=4", ENDITEM, LAST); // 机票信息录入 // web_reg_save_param("departure_city1", // "LB=<td><select name=\"depart\" >", // "RB=</select></td>", // "Ord=all", // "Search=all" // LAST); web_reg_save_param("departure_city1", "LB=<option value=", "RB=>", "Ord=all", "Search=ALL", LAST); web_url("Fight_Order_Button", "{base_url}reservations.pl?page=welcome", "Mode=HTML", LAST); // lr_output_message("-------------%d",lr_paramarr_len("departure_city1")); lr_save_string("Frankfurt","City_1"); lr_save_string("London","City_2"); lr_save_string("Los Angeles","City_3"); lr_save_string("Paris","City_4"); lr_save_string("Portland","City_5"); lr_save_string("San Francisco","City_6"); lr_save_string("Seattle","City_7"); lr_save_string("Sydney","City_8"); lr_save_string("Zurich","City_9"); lr_save_string("Denver","City_10"); lr_save_string("10","City_count"); departure_city = lr_paramarr_random("City"); arrive_city = lr_paramarr_random("City"); while(strcmp(departure_city,arrive_city)==0){ lr_output_message("================> 相同了,重新输入"); arrive_city = lr_paramarr_random("City"); } // lr_output_message("from %s to %s",departure_city, arrive_city); lr_save_string(departure_city,"OF_departure_city"); lr_save_string(arrive_city,"OF_arrive_city"); //选择座位 30%Aisle, 60%window, 10%None srand(time(NULL)); rd_num = rand()%10; // lr_output_message("rd_num is %d",rd_num); if(rd_num>=6 && rd_num<9){ seatPref = "Aisle"; seatType = "Business"; }else if(rd_num>=0 && rd_num<=5){ seatPref = "window"; seatType = "Coach"; }else{ seatPref = "None"; seatType = "First"; } // lr_output_message("choice seatPref is %s", seatPref); // lr_output_message("choice seatType is %s",seatType); lr_save_string(seatPref,"OF_seatPref"); lr_save_string(seatType,"OF_seatType"); //出发日期和返回日期 lr_save_datetime("%m/%d/%Y", (DATE_NOW),"OF_departDate"); lr_save_datetime("%m/%d/%Y", (DATE_NOW+ONE_DAY*(rand()%RECEIVE_DAY)),"OF_returnDate"); // lr_output_message("出发日期: %s,返回日期: %s",lr_eval_string("{OF_departDate}"),lr_eval_string("{OF_returnDate}")); web_reg_save_param("CHOSE_FLIGHT", "LB=name=outboundFlight value=", "RB=>", "Ord=all", "Search=BODY", //"SaveOffset=1", //"SaveLen=18", LAST); web_submit_data("reservations.pl", "Action=http://127.0.0.1:1080/WebTours/reservations.pl", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/reservations.pl?page=welcome", "Snapshot=t26.inf", "Mode=HTML", ITEMDATA, "Name=advanceDiscount", "Value=0", ENDITEM, "Name=depart", "Value={OF_departure_city}", ENDITEM, "Name=departDate", "Value={OF_departDate}", ENDITEM, "Name=arrive", "Value={OF_arrive_city}", ENDITEM, "Name=returnDate", "Value={OF_returnDate}", ENDITEM, "Name=numPassengers", "Value=1", ENDITEM, "Name=seatPref", "Value={OF_seatPref}", ENDITEM, "Name=seatType", "Value={OF_seatType}", ENDITEM, "Name=.cgifields", "Value=roundtrip", ENDITEM, "Name=.cgifields", "Value=seatType", ENDITEM, "Name=.cgifields", "Value=seatPref", ENDITEM, "Name=findFlights.x", "Value=38", ENDITEM, "Name=findFlights.y", "Value=14", ENDITEM, LAST); lr_output_message("-------------%s",lr_paramarr_random("CHOSE_FLIGHT")); for (i=1;i<= atoi(lr_eval_string("{CHOSE_FLIGHT_count}"));i++) { //lr_output_message(">>> %s",lr_paramarr_idx("CHOSE_FLIGHT",i)); code_ticket = (char *)strtok('060;202;10/25/2018',';'); lr_output_message(">>> %s",code_ticket); // while (code_ticket != NULL ) { // While valid tokens are returned // // lr_output_message ("%s", code_ticket ); // // code_ticket = (char *)strtok(NULL, ';'); // Get the next token // // } } // web_submit_data("reservations.pl_2", // "Action=http://127.0.0.1:1080/WebTours/reservations.pl", // "Method=POST", // "TargetFrame=", // "RecContentType=text/html", // "Referer=http://127.0.0.1:1080/WebTours/reservations.pl", // "Snapshot=t27.inf", // "Mode=HTML", // ITEMDATA, // "Name=outboundFlight", "Value=032;345;10/23/2018", ENDITEM, // "Name=numPassengers", "Value=1", ENDITEM, // "Name=advanceDiscount", "Value=0", ENDITEM, // "Name=seatType", "Value=Business", ENDITEM, // "Name=seatPref", "Value=Window", ENDITEM, // "Name=reserveFlights.x", "Value=59", ENDITEM, // "Name=reserveFlights.y", "Value=12", ENDITEM, // LAST); return 0; }
转载请注明原文地址: https://www.6miu.com/read-5039724.html

最新回复(0)