• 飞机订票-4随机删除票务


    Action()
    {
     /*总要求:
     1.页面存在2条以上票务信息,则随机退2张票,若只有1条票务信息,则退1张票;如果没票可退,直接退出.

    使用web_custom_request模拟请求;

    主要问题:没票直接退出,但是会出现找不到参数的问题,需要勾选Run-time Setting-Miscellaneous-Continue on error*/

     int i,len,r1,r2;
     char *Body;//最终拼接
     char r1_temp[64];
     char r2_temp[64];
     char cgifields[32];


        Body=(char *)malloc(10000*sizeof(char));
        srand((unsigned)time(NULL));
        web_set_max_html_param_len("204800");


     /*参数化所有flightID:name="flightID" value="1845222-15462-44"*/
     web_reg_save_param("f_ID",
      "LB=name="flightID" value="",
      "RB="",
      "Ord=All",
      "NotFound=ERROR",
      "Search=Body",
      LAST);
       
     web_reg_find("Search=All",
      "SaveCount=count",
      "Text=A total of ",
      LAST);

     lr_start_transaction("退票");

     web_url("Itinerary Button",
      "URL={url}welcome.pl?page=itinerary",
      "TargetFrame=body",
      "Resource=0",
      "RecContentType=text/html",
      "Referer={url}nav.pl?page=menu&in=home",
      "Snapshot=t6.inf",
      "Mode=HTML",
      LAST);

     if(atoi(lr_eval_string("{count}"))!=0){
      strcpy(Body,"Body=");
     len=lr_paramarr_len("f_ID");
     lr_output_message("机票数目长度:%d",len);

      do{//生成2个不同的随机数
      r1=rand()%len+1;
      r2=rand()%len+1;
     }while(r1==r2);
     lr_output_message("随机删除机票:%d,%d",r1,r2);

     for(i=1;i<=len;i++){
      if(len>=2){//存在2条以上票务信息,则随机退2张票
       if(r1==i){
        strcat(Body,itoa(r1, r1_temp, 10));
        strcat(Body,"=on&");
       } 
       if(r2==i){
        strcat(Body,itoa(r2, r2_temp, 10));
        strcat(Body,"=on&");
       }   
       }
      if(len==1){//只有1条票务信息,则退1张票;
        strcat(Body,"1=on&");
       }
      strcat(Body,"flightID=");
      strcat(Body,lr_paramarr_idx("f_ID",i));
      strcat(Body,"&");
     }

     for(i=1;i<=len;i++){
      sprintf(cgifields,".cgifields=%d%s",i,"&");
      strcat(Body,cgifields);
     }
     strcat(Body,"removeFlights.x=79&removeFlights.y=10");
     lr_output_message("%s",Body);

        web_custom_request ("itinerary.pl_2",
      "URL={url}itinerary.pl",
      "Method=POST",
          Body,
      
      LAST);
    lr_end_transaction("退票",LR_AUTO);
     
      
     }else{
      lr_start_transaction("退出");
      web_url("SignOff Button",
      "URL={url}welcome.pl?signOff=1",
      "TargetFrame=body",
      "Resource=0",
      "RecContentType=text/html",
      "Referer={url}nav.pl?page=menu&in=itinerary",
      "Snapshot=t7.inf",
      "Mode=HTML",
      LAST);
      lr_end_transaction("退出",LR_AUTO);


     }
     


     return 0;
    }

  • 相关阅读:
    将DotNetBar添加到工具箱中
    C#写的CRC16检验算法
    C# 递归程序 获取某个节点下的全部子节点
    软件著作权申请中源代码文档的编辑方法
    c#使用Flash控件AxShockwaveFlash
    国内银行CNAPS CODE 查询
    中国版权保护中心-无法注册的解决办法
    jquery weui做的三级联动
    Validation of viewstate MAC failed 解决办法
    OllyDbg 介绍
  • 原文地址:https://www.cnblogs.com/Miss-Elsa/p/6068428.html
Copyright © 2020-2023  润新知