/// <summary> /// 解析航线信息 /// </summary> /// <param name="strContent">航线内容</param> /// <param name="regexInstance">正则实例</param> /// <returns></returns> public IList <RouteInformation> ParseHtmlCode(string strContent, IRegexExpression regexInstance) { if (string.IsNullOrEmpty(strContent) || regexInstance == null) { return(null); } CtripRegexExpression ctripRegex = (CtripRegexExpression)regexInstance; IList <string> valueList = RegexOperation.GetValuesByRegex(ctripRegex.GetSingleRowRegex(), strContent); IList <RouteInformation> routeInformationList = new List <RouteInformation>(); RouteInformation routeInformation; foreach (string strValue in valueList) { routeInformation = GetRouteInformation(strValue, ctripRegex); if (routeInformation != null) { routeInformation.SeatList = GetSeatInformation(routeInformation, ctripRegex); routeInformationList.Add(routeInformation); } } return(routeInformationList); }
public string RouteTest(string strDeparture, string strArrival, DateTime?departureTime, string strFlightNo) { FactoryContribution factoryContribution = new FactoryContribution(); IRouteFactory routeFactory = factoryContribution.CreateFactory(); if (routeFactory == null) { return(string.Empty); } IRouteOperation routeOperation = routeFactory.CreateRouteInstance(); IRegexExpression regexExpression = routeFactory.CreateRouteRegex(); if (strDeparture.ToUpper().Equals("PEK") || strDeparture.ToUpper().Equals("NAY")) { strDeparture = "BJS"; } if (strArrival.ToUpper().Equals("PEK") || strArrival.ToUpper().Equals("NAY")) { strArrival = "BJS"; } string strUrl = CommonOperation.GetConfigValueByKey(Constant.CCTRIPPATH); if (!string.IsNullOrEmpty(strFlightNo)) { strUrl = CommonOperation.GetConfigValueByKey(Constant.CCTRIPSUBURL); } return(routeOperation.GetHtmlContent(string.Format(strUrl, strDeparture, strArrival, departureTime.Value.ToString("yyyy-MM-dd"), strFlightNo))); }
private IList <RouteInformation> RequestRoute(string strDeparture, string strArrival, DateTime?departureTime) { FactoryContribution factoryContribution = new FactoryContribution(); IRouteFactory routeFactory = factoryContribution.CreateFactory(); if (routeFactory == null) { return(null); } IRouteOperation routeOperation = routeFactory.CreateRouteInstance(); IRegexExpression regexExpression = routeFactory.CreateRouteRegex(); string strUrl = routeOperation.GetRequestUrl(strDeparture, strArrival, departureTime); if (string.IsNullOrEmpty(strUrl)) { return(null); } string strContent = routeOperation.GetHtmlContent(strUrl); IList <RouteInformation> routeInformationList = routeOperation.ParseHtmlCode(strContent, regexExpression); return(routeInformationList); }
/// <summary> /// 解析航线信息 /// </summary> /// <param name="strContent">航线内容</param> /// <param name="regexInstance">正则实例</param> /// <returns></returns> public IList <RouteInformation> ParseHtmlCode(string strContent, IRegexExpression regexInstance) { if (string.IsNullOrEmpty(strContent) || regexInstance == null) { return(null); } ElongRegexEpression etripRegex = (ElongRegexEpression)regexInstance; //StringReader sr = new StringReader(strContent); IList <string> valueList = RegexOperation.GetValuesByRegex(etripRegex.GetSingleRowRegex(), strContent); IList <RouteInformation> ElongrouteInformationList = new List <RouteInformation>(); RouteInformation elongrouteInformation; foreach (string strValue in valueList) { elongrouteInformation = GetElongRouteInformation(strValue.ToString(), etripRegex); if (elongrouteInformation != null) { ElongrouteInformationList.Add(elongrouteInformation); } } return(ElongrouteInformationList); }
/// <summary> /// 执行相应请求 /// </summary> /// <param name="strDeparture">出发地</param> /// <param name="strArrival">到达地</param> /// <param name="departureTime">出发时间</param> private static void RequestInvoke(string strDeparture, string strArrival, DateTime?departureTime) { FactoryContribution factoryContribution = new FactoryContribution(); IRouteFactory routeFactory = factoryContribution.CreateFactory(); if (routeFactory == null) { return; } IRouteOperation routeOperation = routeFactory.CreateRouteInstance(); IRegexExpression regexExpression = routeFactory.CreateRouteRegex(); string strUrl = routeOperation.GetRequestUrl(strDeparture, strArrival, departureTime); if (string.IsNullOrEmpty(strUrl)) { return; } string strContent = routeOperation.GetHtmlContent(strUrl); IList <RouteInformation> routeInformationList = routeOperation.ParseHtmlCode(strContent, regexExpression); CompareCtripLowestPrice(routeInformationList, routeOperation.GetSourceType()); }
public IRegexExpression Parse(string prefix_regex) { // Your Code here List<string> parsedList = prefix_regex.Split(new[] {' ' }).ToList(); IRegexExpression root = recursiveParse(parsedList); return root; //throw new NotImplementedException(); }
/// <summary> /// ����������Ϣ /// </summary> /// <param name="strContent">��������</param> /// <param name="regexInstance">����ʵ��</param> /// <returns></returns> public IList<RouteInformation> ParseHtmlCode(string strContent, IRegexExpression regexInstance) { if (string.IsNullOrEmpty(strContent) || regexInstance == null) return null; VeryTripRegexExpression veryTripRegex = (VeryTripRegexExpression)regexInstance; string strUrl = GetRealQuestUrl(strContent, veryTripRegex); return CombineAllRoute(GetHtmlSource(strUrl), veryTripRegex); }
/// <summary> /// 解析航线信息 /// </summary> /// <param name="strContent">航线内容</param> /// <param name="regexInstance">正则实例</param> /// <returns></returns> public IList <RouteInformation> ParseHtmlCode(string strContent, IRegexExpression regexInstance) { if (string.IsNullOrEmpty(strContent) || regexInstance == null) { return(null); } VeryTripRegexExpression veryTripRegex = (VeryTripRegexExpression)regexInstance; string strUrl = GetRealQuestUrl(strContent, veryTripRegex); return(CombineAllRoute(GetHtmlSource(strUrl), veryTripRegex)); }
/// <summary> /// ����������Ϣ /// </summary> /// <param name="strContent">��������</param> /// <param name="regexInstance">����ʵ��</param> /// <returns></returns> public IList<RouteInformation> ParseHtmlCode(string strContent, IRegexExpression regexInstance) { if (string.IsNullOrEmpty(strContent) || regexInstance == null) return null; ElongRegexEpression etripRegex = (ElongRegexEpression)regexInstance; //StringReader sr = new StringReader(strContent); IList<string> valueList = RegexOperation.GetValuesByRegex(etripRegex.GetSingleRowRegex(), strContent); IList<RouteInformation> ElongrouteInformationList = new List<RouteInformation>(); RouteInformation elongrouteInformation; foreach (string strValue in valueList) { elongrouteInformation = GetElongRouteInformation(strValue.ToString(), etripRegex); if (elongrouteInformation != null) ElongrouteInformationList.Add(elongrouteInformation); } return ElongrouteInformationList; }
private static void ElongInvoke(string strUrl) { FactoryContribution factoryContribution = new FactoryContribution(); IRouteFactory routeFactory = factoryContribution.CreateFactory(); if (routeFactory == null) { return; } IRouteOperation routeOperation = routeFactory.CreateRouteInstance(); IRegexExpression regexExpression = routeFactory.CreateRouteRegex(); string strContent = routeOperation.GetHtmlContent(strUrl); IList <RouteInformation> routeInformationList = routeOperation.ParseHtmlCode(strContent, regexExpression); CompareElongLowestPrice(routeInformationList); }
public SequenceExpression(IRegexExpression lC, IRegexExpression rC) { leftChild = lC; rightChild = rC; }
public RepetitionExpression(IRegexExpression c) { child = c; }
public AlternationExpression(IRegexExpression lC, IRegexExpression rC) { leftChild = lC; rightChild = rC; }