private void getFlightAbout(String html) { int iTableStart = html.IndexOf("stage flights", 0); int iTableEnd = html.IndexOf("</ul>", iTableStart); string strtable = html.Substring(iTableStart, iTableEnd - iTableStart + 5); while (true) { RS_FlightRoute flightAbout = new RS_FlightRoute(); flightAbout.FlightType = "直达"; RS_FlightDetail flightDetail = new RS_FlightDetail(); int startLi = strtable.IndexOf("<li", 0); int endLi = strtable.IndexOf("</li", startLi); int flightStart = strtable.IndexOf("<p class=\"n\">", 0); int flightEnd = strtable.IndexOf("</p>", flightStart); String flight = strtable.Substring(flightStart + 13, flightEnd - flightStart - 13); for (int i = 0; i < flight.Length; i++) { if (flight[i] >= 'A' && flight[i] <= 'Z') { String agency = flight.Substring(0, i); String flightNum = flight.Substring(i); flightDetail.Airline = agency.Trim(); flightDetail.FlightNum = flightNum.Trim(); break; } } int timeStart = strtable.IndexOf("<p class=\"i\">", flightEnd); int timeEnd = strtable.IndexOf("<br", timeStart); String time = strtable.Substring(timeStart + 13, timeEnd - timeStart - 13); String TakeOffTime = time.Substring(0, time.IndexOf("-") - 1); String ArriveTime = time.Substring(time.IndexOf("-") + 2); flightDetail.TakeOffTime = TakeOffTime.Trim(); ; flightDetail.ArriveTime = ArriveTime.Trim(); int portEnd = strtable.IndexOf("</p>", timeEnd); String port = strtable.Substring(timeEnd + 6, portEnd - timeEnd - 6).Trim(); String DPort = port.Substring(0, port.IndexOf("-") - 1); String APort = port.Substring(port.IndexOf("-") + 2); if (APort.IndexOf("<span") > 0) { APort = APort.Substring(0, APort.IndexOf("<span") - 1) + "(经停)"; } flightDetail.DPort = DPort.Trim(); flightDetail.APort = APort.Trim(); String agencyUrl = "http://touch.qunar.com/flightDetail.jsp?flightType=oneWay&startCity=" + startCity + "&destCity=" + destCity + "&startDate=" + startDate + "&code=" + flightDetail.FlightNum + "&minPrice=&bd_source=qunar"; String agencyHtml = getWebHtml(agencyUrl); int priceStart = agencyHtml.IndexOf("¥", 0); int priceEnd = agencyHtml.IndexOf("</em>", priceStart); flightDetail.MinPrice = agencyHtml.Substring(priceStart + 5, priceEnd - priceStart - 5); flightDetail.AgencyList = getFlightAgency(agencyHtml); flightAbout.addDetail(flightDetail); flightInfo.addAbout(flightAbout); if (strtable.IndexOf("<li", portEnd) > 0) strtable = strtable.Substring(strtable.IndexOf("<li", portEnd)); else break; } }
private void getFlightAbout(String html) { int iTableStart = html.IndexOf("stage flights", 0); int iTableEnd = html.IndexOf("</ul>", iTableStart); string strtable = html.Substring(iTableStart, iTableEnd - iTableStart); while (true) { RS_FlightRoute flightAbout = new RS_FlightRoute(); flightAbout.FlightType = "往返"; int startLi = strtable.IndexOf("<li", 0); int endLi = strtable.IndexOf("</li", startLi); int startDl = strtable.IndexOf("<dl>", startLi); int endDl = strtable.IndexOf("</dl>", startDl); RS_FlightDetail flightBegin = getFlightDetail(strtable.Substring(startDl, endDl - startDl)); String agencyUrl = "http://touch.qunar.com/flightDetail.jsp?sort=1&flightType=oneWay&startCity=" + startCity + "&destCity=" + destCity + "&startDate=" + startDate + "&filter=&code=" + flightBegin.FlightNum + "&filterValue=&ifShowMultWay=-1&bd_source=qunar"; String agencyHtml = getWebHtml(agencyUrl); int priceStart = agencyHtml.IndexOf("¥", 0); int priceEnd = agencyHtml.IndexOf("</em>", priceStart); flightBegin.MinPrice = agencyHtml.Substring(priceStart + 5, priceEnd - priceStart - 5); flightBegin.AgencyList = getFlightAgency(agencyHtml); startDl = strtable.IndexOf("<dl>", endDl); endDl = strtable.IndexOf("</dl>", startDl); RS_FlightDetail flightBack = getFlightDetail(strtable.Substring(startDl, endDl - startDl)); String backUrl = "http://touch.qunar.com/flightDetail.jsp?sort=1&flightType=oneWay&startCity=" + destCity + "&destCity=" + startCity + "&startDate=" + backDate + "&filter=&code=" + flightBack.FlightNum + "&filterValue=&ifShowMultWay=-1&bd_source=qunar"; String backHtml = getWebHtml(backUrl); priceStart = backHtml.IndexOf("¥", 0); priceEnd = backHtml.IndexOf("</em>", priceStart); flightBack.MinPrice = backHtml.Substring(priceStart + 5, priceEnd - priceStart - 5); flightBack.AgencyList = getFlightAgency(backHtml); flightAbout.addDetail(flightBegin); flightAbout.addDetail(flightBack); flightInfo.addAbout(flightAbout); if (strtable.IndexOf("<li", endLi) > 0) strtable = strtable.Substring(strtable.IndexOf("<li", endLi)); else break; } }
public void addAbout(RS_FlightRoute flightAbout) { RouteList.Add(flightAbout); }