web_url("Search Flights Button", "URL=http://127.0.0.1:1080/WebTours/welcome.pl?page=search", "TargetFrame=body", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home", "Snapshot=t16.inf", "Mode=HTML", LAST); lr_think_time(21); 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=t17.inf", "Mode=HTML", ITEMDATA, "Name=advanceDiscount", "Value=0", ENDITEM, "Name=depart", "Value=London", ENDITEM, "Name=departDate", "Value=02/24/2017", ENDITEM, "Name=arrive", "Value=San Francisco", ENDITEM, "Name=returnDate", "Value=02/25/2017", ENDITEM, "Name=numPassengers", "Value=2", ENDITEM, "Name=seatPref", "Value=Aisle", ENDITEM, "Name=seatType", "Value=First", ENDITEM, "Name=.cgifields", "Value=roundtrip", ENDITEM, "Name=.cgifields", "Value=seatType", ENDITEM, "Name=.cgifields", "Value=seatPref", ENDITEM, "Name=findFlights.x", "Value=65", ENDITEM, "Name=findFlights.y", "Value=7", ENDITEM, LAST); 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=t18.inf", "Mode=HTML", ITEMDATA, "Name=outboundFlight", "Value=260;1099;02/24/2017", ENDITEM, "Name=numPassengers", "Value=2", ENDITEM, "Name=advanceDiscount", "Value=0", ENDITEM, "Name=seatType", "Value=First", ENDITEM, "Name=seatPref", "Value=Aisle", ENDITEM, "Name=reserveFlights.x", "Value=66", ENDITEM, "Name=reserveFlights.y", "Value=15", ENDITEM, LAST); lr_think_time(9); web_submit_data("reservations.pl_3", "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=t19.inf", "Mode=HTML", ITEMDATA, "Name=firstName", "Value=Joseph", ENDITEM, "Name=lastName", "Value=Marshall", ENDITEM, "Name=address1", "Value=234 Willow Drive", ENDITEM, "Name=address2", "Value=San Jose/CA/94085", ENDITEM, "Name=pass1", "Value=Joseph Marshall", ENDITEM, "Name=pass2", "Value=", ENDITEM, "Name=creditCard", "Value=123456", ENDITEM, "Name=expDate", "Value=0223", ENDITEM, "Name=oldCCOption", "Value=", ENDITEM, "Name=numPassengers", "Value=2", ENDITEM, "Name=seatType", "Value=First", ENDITEM, "Name=seatPref", "Value=Aisle", ENDITEM, "Name=outboundFlight", "Value=260;1099;02/24/2017", ENDITEM, "Name=advanceDiscount", "Value=0", ENDITEM, "Name=returnFlight", "Value=", ENDITEM, "Name=JSFormSubmit", "Value=off", ENDITEM, "Name=.cgifields", "Value=saveCC", ENDITEM, "Name=buyFlights.x", "Value=39", ENDITEM, "Name=buyFlights.y", "Value=10", ENDITEM, LAST); web_submit_data("reservations.pl_4", "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=t20.inf", "Mode=HTML", ITEMDATA, "Name=Book Another.x", "Value=57", ENDITEM, "Name=Book Another.y", "Value=17", ENDITEM, LAST); web_url("SignOff Button", "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1", "TargetFrame=body", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=flights", "Snapshot=t21.inf", "Mode=HTML", LAST); return 0; }
黄色部分正好是选择出发城市和目的城市之后的页面出现的四种机票之一,要想在脚本回放的过程中,无论前一页选择了什么出发城市和目的城市,然后在这一页都能随机的选择一种机票所以此处黄色部分可以先关联出来,然后直接用参数替代,就可以达到想要的效果了
服务器应答内容:
<center> <!-- From London (2) To San Francisco (6) --> <table cellspacing=2 border=0 width=50%> <blockquote>Flight departing from <B>London</B> to <B>San Francisco</B> on <B>02/24/2017</B><BR><BR> <tr bgcolor=#5E7884><td align=center><font color=white><B>Flight</B></font> <td align=center><font color=white><B>Departure time</B> <td align=center><font color=white><B>Cost</B> <tr bgcolor=#EFF2F7><td align=center><input type = radio name=outboundFlight value=260;1099;02/24/2017 checked >Blue Sky Air 260<td align=center>8am<td align=center>$ 1099</TD></TR><tr bgcolor=#EFF2F7><td align=center><input type = radio name=outboundFlight value=261;979;02/24/2017>Blue Sky Air 261<td align =center>1pm<td align=center>$ 979</TD></TR><tr bgcolor=#EFF2F7><td align=center><input type = radio name =outboundFlight value=262;1039;02/24/2017>Blue Sky Air 262<td align=center>5pm<td align=center>$ 1039 </TD></TR><tr bgcolor=#EFF2F7><td align=center><input type = radio name=outboundFlight value=263;899 ;02/24/2017>Blue Sky Air 263<td align=center>11pm<td align=center>$ 899</TD></TR></table> //拆分一下页面4种选择 name=outboundFlight value=260;1099;02/24/2017checked >Blue Sky Air 260<td name=outboundFlight value=261;979;02/24/2017>Blue Sky Air 261<td name=outboundFlight value=262;1039;02/24/2017>Blue Sky Air 262<td name=outboundFlight value=263;899;02/24/2017>Blue Sky Air 263<td align=center>11pm<td
根据多次出发城市和到达城市匹配 每次页面都会有1个这样的值name=outboundFlight value=260;1099;02/24/2017checked >Blue Sky Air 260<td"
需要关联动态值:260;1099;02/24/2017
确定左右边界值, 这里我把左边界设置outboundFlight value= 右边界2017、然后再最下面{Flight}2017直接拼接就可以用了
web_reg_save_param("Flight", "LB=name=outboundFlight value=", "RB=2017", // "Ord=3", LAST);//关联服务器根据每次选择的出发城市与目标城市动态航班次机以及机票价格
关联成功后 运行结果如下:
Action.c(101): 100;386;02/21/ //航班班次 票价 出发日期 Action.c(102): Frankfurt,Denver //出发城市 到底城市 Action.c(101): 210;266;02/21/ Action.c(102): London,Frankfurt Action.c(101): 320;773;02/21/ Action.c(102): Los Angeles,London Action.c(101): 430;438;02/21/ Action.c(102): Paris,Los Angeles Action.c(101): 540;621;02/21/ Action.c(102): Portland,Paris
时间: 2025-01-19 23:32:40