private IList <Seat> GetSeatInformation(string strContent, VeryTripRegexExpression veryTripRegex) { IList <Seat> seatList = new List <Seat>(); Seat seat; IList <string> secondContentList = RegexOperation.GetValuesByRegex(veryTripRegex.GetSingleRowSecondRegex(), strContent); if (secondContentList == null) { return(seatList); } string strPrice = string.Empty; foreach (string strResult in secondContentList) { seat = new Seat(); seat.Cabin = RegexOperation.GetValueByRegex(veryTripRegex.GetCabinRegex(), strResult); strPrice = RegexOperation.GetValueByRegex(veryTripRegex.GetTicketPriceRegex(), strResult); if (!string.IsNullOrEmpty(strPrice)) { seat.Price = double.Parse(strPrice); } seat.Count = 9; seat.SubCanbin = RegexOperation.GetValueByRegex(veryTripRegex.GetSubCanbin(), strResult); seatList.Add(seat); } return(seatList); }
private IList <Seat> GetSeatInformation(RouteInformation routeInformation, CtripRegexExpression ctripRegex) { IList <Seat> seatList = new List <Seat>(); Seat seat; string strUrl = GetUrl(routeInformation.OriginalAirport, routeInformation.DestinationAirport, routeInformation.DepartureTime, routeInformation.FlightNO); IList <string> resultList = RegexOperation.GetValuesByRegex(string.Format(ctripRegex.GetAllCabinInfomation(), routeInformation.FlightNO.Trim()), DownHtmlSource(strUrl)); if (resultList == null) { return(seatList); } string strPrice = string.Empty; foreach (string strResult in resultList) { seat = new Seat(); seat.Cabin = RegexOperation.GetValueByRegex(ctripRegex.GetOtherCanbin(), strResult); strPrice = RegexOperation.GetValueByRegex(ctripRegex.GetOtherCanbinPrice(), strResult); if (!string.IsNullOrEmpty(strPrice)) { seat.Price = double.Parse(strPrice); } seat.Count = 9; seatList.Add(seat); } return(seatList); }
private string ControlResponse(string strUrl) { if (string.IsNullOrEmpty(strUrl)) { return(string.Empty); } string strRegexExpression = CommonOperation.GetConfigValueByKey(Constant.CTRAVELSKY); string strDeparture = RegexOperation.GetValueByRegex(string.Format(strRegexExpression, Constant.CORGCITY), strUrl); string strArrival = RegexOperation.GetValueByRegex(string.Format(strRegexExpression, Constant.CDSTCITY), strUrl); string strDepartureTime = RegexOperation.GetValueByRegex(string.Format(strRegexExpression, Constant.CFLYDATE), strUrl); DateTime?departureTime = Convert.ToDateTime(strDepartureTime.Substring(0, 4) + "-" + strDepartureTime.Substring(4, 2) + "-" + strDepartureTime.Substring(6, 2)); IList <RouteInformation> routeInformationList = RequestRoute(strDeparture, strArrival, departureTime); if (routeInformationList == null) { return(string.Empty); } return(CommonOperation.GetXmlOfFlightInformation(routeInformationList)); }
private string GetNomalFragment(string strContent, VeryTripRegexExpression veryRegexInstance) { string strNomalContent = RegexOperation.GetValueByRegex(veryRegexInstance.GetNormalFragmentRegex(), strContent); if (!string.IsNullOrEmpty(strNomalContent)) { strNomalContent += Constant.CMATCHSIGN; } return(strNomalContent); }
private IList <string> GetPageUrl(string strContent, VeryTripRegexExpression veryRegexInstance) { IList <string> pageUrlList = new List <string>(); string strPages = RegexOperation.GetValueByRegex(veryRegexInstance.GetPageFragmentRegex(), strContent); if (string.IsNullOrEmpty(strPages)) { return(pageUrlList); } IList <string> suffixUrlList = RegexOperation.GetValuesByRegex(veryRegexInstance.GetPageLinkRegex(), strPages); foreach (string strSuffixUrl in suffixUrlList) { pageUrlList.Add(GetPrefixUrl() + strSuffixUrl); } return(pageUrlList); }
private RouteInformation GetRouteInformation(string strContent, CtripRegexExpression ctripRegex) { if (string.IsNullOrEmpty(strContent)) { return(null); } string strTbodyData = RegexOperation.GetValueByRegex(ctripRegex.GetTbodyDataRegex(), strContent); if (string.IsNullOrEmpty(strTbodyData)) { return(null); } RouteInformation routeInformation = new RouteInformation(); IList <string> valueList; valueList = RegexOperation.GetValuesByRegex(ctripRegex.GetCityRegex(), strContent); if (valueList != null && valueList.Count == 2) { routeInformation.OriginalAirport = valueList[0]; routeInformation.DestinationAirport = valueList[1]; } valueList = RegexOperation.GetValuesByRegex(ctripRegex.GetDateRegex(), strContent); if (valueList != null && valueList.Count == 2) { if (!string.IsNullOrEmpty(valueList[0])) { routeInformation.DepartureTime = DateTime.Parse(valueList[0]); } if (!string.IsNullOrEmpty(valueList[1])) { routeInformation.ArriveTime = DateTime.Parse(valueList[1]); } } routeInformation.AirDate = routeInformation.DepartureTime; string strDiscount = RegexOperation.GetValueByRegex(ctripRegex.GetDiscountRegex(), strTbodyData); if (!string.IsNullOrEmpty(strDiscount)) { routeInformation.Discount = double.Parse(strDiscount); } string strTicketPrice = RegexOperation.GetValueByRegex(ctripRegex.GetTicketPriceRegex(), strTbodyData); if (!string.IsNullOrEmpty(strTicketPrice)) { routeInformation.TicketPrice = double.Parse(strTicketPrice); } routeInformation.Meal = RegexOperation.GetValueByRegex(ctripRegex.GetMealRegex(), strTbodyData); routeInformation.AirLine = RegexOperation.GetValueByRegex(ctripRegex.GetAirLineRegex(), strTbodyData); routeInformation.ChangeRule = RegexOperation.GetValueByRegex(ctripRegex.GetChangeRuleRegex(), strContent); routeInformation.FlightInterval = RegexOperation.GetValueByRegex(ctripRegex.GetFlightIntervalRegex(), strContent); routeInformation.FlightNO = RegexOperation.GetValueByRegex(ctripRegex.GetFlightNORegex(), strContent); routeInformation.FlightType = RegexOperation.GetValueByRegex(ctripRegex.GetFlightTypeRegex(), strContent); routeInformation.ChangeRule = RegexOperation.GetValueByRegex(ctripRegex.GetChangeRuleRegex(), strContent); routeInformation.Cabin = RegexOperation.GetValueByRegex(ctripRegex.GetCabinRegex(), strContent); string strYprice = RegexOperation.GetValueByRegex(ctripRegex.GetYpriceRegex(), strContent); if (!string.IsNullOrEmpty(strYprice)) { routeInformation.Yprice = double.Parse(strYprice); } string strAirportFuelTax = RegexOperation.GetValueByRegex(ctripRegex.GetAirportFuelRegex(), strContent); if (!string.IsNullOrEmpty(strAirportFuelTax)) { string[] strDatas = strAirportFuelTax.Split('+'); if (!string.IsNullOrEmpty(strDatas[0])) { routeInformation.AirportTax = double.Parse(strDatas[0]); } if (!string.IsNullOrEmpty(strDatas[1])) { routeInformation.FuelTax = double.Parse(strDatas[1]); } } return(routeInformation); }
private string GetRealQuestUrl(string strContent, VeryTripRegexExpression veryTripRegex) { return(GetPrefixUrl() + RegexOperation.GetValueByRegex(veryTripRegex.GetWaitingSuffixRegex(), strContent)); }
private RouteInformation GetRouteInformation(string strContent, VeryTripRegexExpression veryTripRegex) { if (string.IsNullOrEmpty(strContent)) { return(null); } string strFirstContent = RegexOperation.GetValueByRegex(veryTripRegex.GetSingleRowFirstRegex(), strContent); if (string.IsNullOrEmpty(strFirstContent)) { return(null); } RouteInformation routeInformation = new RouteInformation(); routeInformation.OriginalAirport = RegexOperation.GetValueByRegex(veryTripRegex.GetDepartureCityRegex(), strFirstContent); routeInformation.DestinationAirport = RegexOperation.GetValueByRegex(veryTripRegex.GetArrivalCityRegex(), strFirstContent); if (GetFlightDate().HasValue) { string strStartTime = RegexOperation.GetValueByRegex(veryTripRegex.GetDepartureTimeRegex(), strFirstContent); string strEndTime = RegexOperation.GetValueByRegex(veryTripRegex.GetArrivalTimeRegex(), strFirstContent); routeInformation.DepartureTime = DateTime.Parse(GetFlightDate().Value.ToString("yyyy-MM-dd") + " " + strStartTime + ":00"); routeInformation.ArriveTime = DateTime.Parse(GetFlightDate().Value.ToString("yyyy-MM-dd") + " " + strEndTime + ":00"); routeInformation.AirDate = GetFlightDate().Value; } //routeInformation.Discount = double.Parse(strDiscount); //string strTicketPrice = RegexOperation.GetValueByRegex(veryTripRegex.GetTicketPriceRegex(), strTbodyData); //if (!string.IsNullOrEmpty(strTicketPrice)) // routeInformation.TicketPrice = double.Parse(strTicketPrice); //routeInformation.Meal = RegexOperation.GetValueByRegex(veryTripRegex.GetMealRegex(), strTbodyData); //routeInformation.AirLine = RegexOperation.GetValueByRegex(veryTripRegex.GetAirLineRegex(), strTbodyData); //routeInformation.ChangeRule = RegexOperation.GetValueByRegex(veryTripRegex.GetChangeRuleRegex(), strContent); //routeInformation.FlightInterval = RegexOperation.GetValueByRegex(veryTripRegex.GetFlightIntervalRegex(), strContent); routeInformation.FlightNO = RegexOperation.GetValueByRegex(veryTripRegex.GetFlightNORegex(), strFirstContent); routeInformation.AirLine = routeInformation.FlightNO.Substring(0, 2); routeInformation.FlightType = RegexOperation.GetValueByRegex(veryTripRegex.GetFlightTypeRegex(), strFirstContent); string strStops = RegexOperation.GetValueByRegex(veryTripRegex.GetStops(), strFirstContent); if (!string.IsNullOrEmpty(strStops)) { routeInformation.Stops = int.Parse(strStops); } //routeInformation.Cabin = RegexOperation.GetValueByRegex(veryTripRegex.GetCabinRegex(), strContent); string strYprice = RegexOperation.GetValueByRegex(veryTripRegex.GetYpriceRegex(), strFirstContent); if (!string.IsNullOrEmpty(strYprice)) { routeInformation.Yprice = double.Parse(strYprice); } //string strAirportFuelTax = RegexOperation.GetValueByRegex(veryTripRegex.GetAirportFuelRegex(), strContent); //if (!string.IsNullOrEmpty(strAirportFuelTax)) //{ // string[] strDatas = strAirportFuelTax.Split('+'); // if (!string.IsNullOrEmpty(strDatas[0])) // routeInformation.AirportTax = double.Parse(strDatas[0]); // if (!string.IsNullOrEmpty(strDatas[1])) // routeInformation.FuelTax = double.Parse(strDatas[1]); //} return(routeInformation); }
/// <summary> /// 获取艺龙航线信息 /// </summary> /// <param name="strContent"></param> /// <param name="etripRegex"></param> /// <returns></returns> private RouteInformation GetElongRouteInformation(string strContent, ElongRegexEpression etripRegex) { if (string.IsNullOrEmpty(strContent)) { return(null); } string strRule = RegexOperation.GetValueByRegex(etripRegex.GetRuleData(), strContent); string strTable = RegexOperation.GetValueByRegex(etripRegex.GetSingleRowRegex(), strContent); if (string.IsNullOrEmpty(strTable)) { return(null); } string airline = RegexOperation.GetValueByRegex(etripRegex.GetAirLineRegex(), strContent); if (string.IsNullOrEmpty(airline)) { return(null); } RouteInformation elongrouteInformation = new RouteInformation(); IList <string> valueList; //出发城市、到大城市 valueList = RegexOperation.GetValuesByRegex(etripRegex.GetCityRegex(), strContent); if (valueList != null && valueList.Count == 2) { elongrouteInformation.OriginalAirport = valueList[0]; elongrouteInformation.DestinationAirport = valueList[1]; } //出发城市 //elongrouteInformation.OriginalAirport = RegexOperation.GetValuesByRegex(etripRegex.GetDepartureCityRegex(), strContent).ToString(); //到达城市 // elongrouteInformation.DestinationAirport = RegexOperation.GetValuesByRegex(etripRegex.GetArrivalCityRegex(), strContent).ToString(); //航空公司 elongrouteInformation.AirLine = RegexOperation.GetValueByRegex(etripRegex.GetAirLineRegex(), strTable).ToString(); //航班号 elongrouteInformation.FlightNO = RegexOperation.GetValueByRegex(etripRegex.GetFlightNORegex(), strContent).ToString(); //舱位 elongrouteInformation.Cabin = RegexOperation.GetValueByRegex(etripRegex.GetCabinRegex(), strContent).ToString(); //机型 elongrouteInformation.FlightType = RegexOperation.GetValueByRegex(etripRegex.GetFlightTypeRegex(), strRule).ToString(); //退改 elongrouteInformation.ChangeRule = RegexOperation.GetValueByRegex(etripRegex.GetChangeRuleRegex(), strContent).ToString(); //折扣 elongrouteInformation.Ediscount = RegexOperation.GetValueByRegex(etripRegex.GetDiscountRegex(), strContent).ToString(); //税费 string eAirportFuel = RegexOperation.GetValueByRegex(etripRegex.GetEAirportFuelRegex(), strTable).ToString(); if (!string.IsNullOrEmpty(eAirportFuel)) { elongrouteInformation.Eairportfuel = double.Parse(eAirportFuel); } //机建 string airPort = RegexOperation.GetValueByRegex(etripRegex.GetAirportRegex(), strContent).ToString(); if (!string.IsNullOrEmpty(airPort)) { elongrouteInformation.AirportTax = double.Parse(airPort); } //燃油 string fuel = RegexOperation.GetValueByRegex(etripRegex.GetFuelRegex(), strContent).ToString(); if (!string.IsNullOrEmpty(fuel)) { elongrouteInformation.FuelTax = double.Parse(fuel); } //票价 string ticketPrice = RegexOperation.GetValueByRegex(etripRegex.GetTicketPriceRegex(), strContent).ToString(); if (!string.IsNullOrEmpty(ticketPrice)) { elongrouteInformation.TicketPrice = double.Parse(ticketPrice); } string yearmonthday = RegexOperation.GetValueByRegex(etripRegex.GetYearMonthDay(), strRule).ToString(); //出发时间 string departureTime = RegexOperation.GetValueByRegex(etripRegex.GetDepartureTimeRegex(), strContent).ToString(); string yd = yearmonthday + " " + departureTime; if (!string.IsNullOrEmpty(departureTime)) { elongrouteInformation.DepartureTime = DateTime.Parse(yd); } //到达时间 string arrivalTime = RegexOperation.GetValueByRegex(etripRegex.GetArrivalTimeRegex(), strContent).ToString(); string ya = yearmonthday + " " + arrivalTime; if (!string.IsNullOrEmpty(arrivalTime)) { elongrouteInformation.ArriveTime = DateTime.Parse(ya); } return(elongrouteInformation); }