|
可参考:
http://www.cnblogs.com/guanhe/archive/2006/09/04/494223.html
摘取内容如下:
web_custom_request方法的原型是:
int web_custom_request (const char *RequestName, <List of Attributes>,[EXTRARES, <List of Resource Attributes>,] LAST );
其中List of Attributes的主要项目是Method,URL和BODY等。对这个例子来说,我们可以很容易构造出我们需要的request的BODY内容。
……
strcpy(creq, "Body=1=on&flightID=");
strcat(creq, lr_eval_string("{fID1}"));
strcat(creq, "&2=on&flightID=");
strcat(creq, lr_eval_string("{fID2}"));
strcat(creq, "&.cgifields=1&.cgifields=2");
strcat(creq, "&removeFlights.x=116&removeFlights.y=8");
其中{fID1}、{fID2}等都是通过关联获得的flightID的数据。
因此,我们可以根据图中的数据编写custom_request语句:
web_custom_request("itinerary.pl",
"Method=POST",
"URL=http://localhost/MercuryWebTours/itinerary.pl",
"RecContentType=text/xml",
creq,
"Snapshot=t4.inf",
LAST);
较为完整的代码如下: Action()
{
char creq[500];
web_reg_save_param("fID1", "LB=INPUT TYPE=\"hidden\" NAME=\"flightID\" VALUE=\"", "RB=\"", "ORD=1",
"SEARCH=BODY", LAST);
web_reg_save_param("fID2", "LB=INPUT TYPE=\"hidden\" NAME=\"flightID\" VALUE=\"", "RB=\"", "ORD=2",
"SEARCH=BODY", LAST);
web_url("welcome.pl",
"URL=http://localhost/MercuryWebTours/welcome.pl?page=itinerary",
"Resource=0",
"RecContentType=text/html",
"Referer=http://localhost/MercuryWebTours/nav.pl?page=menu&in=home",
"Snapshot=t3.inf",
"Mode=HTML",
EXTRARES,
"URL=images/in_itinerary.gif", "Referer=http://localhost/MercuryWebTours/nav.pl?page=menu&in=itinerary", ENDITEM,
"URL=images/home.gif", "Referer=http://localhost/MercuryWebTours/nav.pl?page=menu&in=itinerary", ENDITEM,
LAST);
lr_think_time(2);
strcpy(creq, "Body=1=on&flightID=");
strcat(creq, lr_eval_string("{fID1}"));
strcat(creq, "&2=on&flightID=");
strcat(creq, lr_eval_string("{fID2}"));
strcat(creq, "&.cgifields=1&.cgifields=2");
strcat(creq, "&removeFlights.x=116&removeFlights.y=8");
lr_output_message(creq);
web_custom_request("itinerary.pl",
"Method=POST",
"URL=http://localhost/MercuryWebTours/itinerary.pl",
"RecContentType=text/xml",
creq,
"Snapshot=t4.inf",
LAST);
return 0;
} |
|