private string getGetData(SearchInputService input) { StringBuilder get = new StringBuilder("?"); get.Append("culture=vi-VN"); string type = ""; if (input.IsRoundTrip) { type = "RoundTrip"; } else { type = "OneWay"; } get.Append("&RadioButtonMarketStructure="+type); get.Append("&Origin1="+input.DepartureCode); get.Append("&Destination1="+input.ArrivalCode); get.Append("&Day1="+input.DepartTime.Day); get.Append("&MonthYear1="+input.DepartTime.Year+"-"+input.DepartTime.Month); get.Append("&Origin2="+input.ArrivalCode); get.Append("&Destination2="+input.DepartureCode); get.Append("&Day2="+input.ReturnTime.Day); get.Append("&MonthYear2=" + input.ReturnTime.Year + "-" + input.ReturnTime.Month); get.Append("&ADT="+input.Adults); get.Append("&CHD="+input.Children); get.Append("&INFANT="+input.Inf); get.Append("&AutoSubmit=Y&ControlGroupCalendarSearchView$AvailabilitySearchInputCalendarSearchView$DropDownListCurrency=VND"); return get.ToString(); }
public RootMinPrice GetPriceInFare(SearchInputService input) { try { CrawlerHelper helper = new CrawlerHelper(); CookieCollection cookieCollection = helper.getCookieCollection("https://ameliaweb5.intelisys.ca/VietJet/ameliapost.aspx?lang=vi", "POST", getPostdata(input)); HtmlDocument htmld = helper.getDocument("https://ameliaweb5.intelisys.ca/VietJet/ameliapost.aspx?lang=vi", "POST", getPostdata2(input), cookieCollection); //File.WriteAllText("D:",htmld.DocumentNode.InnerHtml); HtmlNode nodeTemp = htmld.DocumentNode.SelectSingleNode("//div[@id='vvDepDiv']/table"); RootMinPrice root = new RootMinPrice(); root.departurePrices = new OutInBoundPrices(); root.departurePrices.prices = GetListPrices(nodeTemp, input.DepartTime); if (input.IsRoundTrip) { root.arrivePrices = new OutInBoundPrices(); nodeTemp = htmld.DocumentNode.SelectSingleNode("//div[@id='vvRetDiv']/table"); root.arrivePrices.prices = GetListPrices(nodeTemp, input.ReturnTime); } return root; } catch { return null; } }
public Root CreateXmlDocument(SearchInputService input) { try { CrawlerHelper helper = new CrawlerHelper(); Root root = new Root(); root.Departure = input.DepartureCode; root.Arrival = input.ArrivalCode; CookieCollection cookieCollection = helper.getCookieCollection("https://ameliaweb5.intelisys.ca/VietJet/ameliapost.aspx?lang=vi", "POST", getPostdata(input)); HtmlDocument htmld = helper.getDocument("https://ameliaweb5.intelisys.ca/VietJet/ameliapost.aspx?lang=vi", "POST", getPostdata2(input), cookieCollection); root.outBound = new OutInBound(); root.inBound = new OutInBound(); root.AirLine = AirLineName.vietJetAir; HtmlNodeCollection collection; try { collection = htmld.DocumentNode.SelectNodes("//div[@id='toDepDiv']/div[@id='travOpsMain']/table[1]/tr[7]/td/table[1]/tr"); root.outBound.Items = getitems(input.DepartTime,input, collection); } catch { } //chieu ve if (input.IsRoundTrip) { collection = htmld.DocumentNode.SelectNodes("//div[@id='toRetDiv']/div[@id='travOpsMain']/table[1]/tr[7]/td/table[1]/tr"); root.inBound.Items = getitems(input.ReturnTime,input, collection); } return root; } catch { return null; } }
public RootForeign CreateXmlDocument(SearchInputService input) { try { string adress = "https://abacuswebstart.abacus.com.sg/thong-minh/flight-search-process.aspx"; CookieCollection c = crawlerHelper.getCookieCollection(adress, "POST", getPostdata(input)); adress = "https://abacuswebstart.abacus.com.sg/thong-minh/ajax-flight.aspx"; HtmlDocument d = crawlerHelper.getDocument(adress, "POST", getPostdata2(), c); d.DocumentNode.InnerHtml = d.DocumentNode.InnerHtml.Replace("<![CDATA[", " "); //tao doi tuong RootForeign rootf = new RootForeign(); rootf.Departure = input.DepartureCode; rootf.Arrival = input.ArrivalCode; rootf.Flights = new List<FlightForeign>(); HtmlNodeCollection nodeColection = d.DocumentNode.SelectNodes("//div[@class='wsFlightResult wsFlightResultBorder']"); int i = 0; foreach (HtmlNode node in nodeColection) { try { FlightForeign flight = new FlightForeign(); flight.Id = i; i++; flight.outBoundForeign = new OutInBoundForeign(); flight.inBoundForeign = new OutInBoundForeign(); flight.Source = AirLineName.abacus; HtmlNode nodeFlight = node.SelectSingleNode("div/div[2]"); HtmlNode nodeDepart = nodeFlight.SelectSingleNode("div[1]"); flight.outBoundForeign.Segments = getSegments(input.DepartTime, nodeDepart, flight.outBoundForeign); if (input.IsRoundTrip) { HtmlNode nodeReturn = nodeFlight.SelectSingleNode("div[3]"); flight.inBoundForeign.Segments = getSegments(input.ReturnTime, nodeReturn, flight.inBoundForeign); } //lay gia tong HtmlNode nodePrice = node.SelectSingleNode("div/div[1]/div[3]"); flight.Price = decimal.Parse(nodePrice.InnerText) * MoneyRate.MONEY_RATE; //lay gia chi tiet HtmlNode nodePriceDetail = node.SelectSingleNode("div/div[1]/div[5]/table"); getPriceDetail(input, nodePriceDetail, flight); rootf.Flights.Add(flight); } catch { } } ////ghi ra file xml //XmlSerializer serializer = new XmlSerializer(typeof(RootForeign)); //TextWriter writer1 = new StreamWriter(folderPath + "Abacus_"+input.SessionId+".xml"); //serializer.Serialize(writer1, rootf); //writer1.Close(); return rootf; } catch { return null; } }
public RootForeign CrawlerTigerair(int Adults, string ArrivalCode, int Children, DateTime DepartTime, string DepartureCode, int Inf, bool IsRoundTrip, DateTime ReturnTime) { SearchInputService searchInput = new SearchInputService(Adults, ArrivalCode, Children, DepartTime, DepartureCode, Inf, IsRoundTrip, ReturnTime, true); Tigerair bl = new Tigerair(); return bl.CreateXmlDocument(searchInput).Convert2RootForeign(searchInput.IsRoundTrip); }
public RootForeign CrawlerAbacus(int Adults, string ArrivalCode, int Children, DateTime DepartTime, string DepartureCode, int Inf, bool IsRoundTrip, DateTime ReturnTime) { RootForeign rootf = null; try { Abacus abacus = new Abacus(); SearchInputService searchInput = new SearchInputService(Adults, ArrivalCode, Children, DepartTime, DepartureCode, Inf, IsRoundTrip, ReturnTime,false); rootf=abacus.CreateXmlDocument(searchInput); } catch { } return rootf; }
public RootForeign CrawlerAirAsia(int Adults, string ArrivalCode, int Children, DateTime DepartTime, string DepartureCode, int Inf, bool IsRoundTrip, DateTime ReturnTime) { RootForeign rootf = null; try { AirAsia airAsia = new AirAsia(); SearchInputService searchInput = new SearchInputService(Adults, ArrivalCode, Children, DepartTime, DepartureCode, Inf, IsRoundTrip, ReturnTime, false); rootf = airAsia.CreateXmlDocument(searchInput).Convert2RootForeign(searchInput.IsRoundTrip); } catch { } return rootf; }
public RootMinPrice GetPriceInFare(SearchInputService input) { CrawlerHelper helper = new CrawlerHelper(); CookieCollection c = helper.getCookieCollection("http://booknow.jetstar.com/lowfarefinder.aspx", "GET", getGetData(input)); HtmlDocument htmld = helper.getDocument("http://booknow.jetstar.com/lowfarefinder.aspx", "GET", getGetData(input), c); HtmlNodeCollection nodeTemp = htmld.DocumentNode.SelectNodes("//div[@id='departing-flight']/div/div[@class='low-fare-selector']/ul/li"); RootMinPrice root = new RootMinPrice(); root.departurePrices = new OutInBoundPrices(); root.departurePrices.prices = GetListPrices(nodeTemp); root.arrivePrices = new OutInBoundPrices(); nodeTemp = htmld.DocumentNode.SelectNodes("//div[@id='returning-flight']/div/div[@class='low-fare-selector']/ul/li"); root.arrivePrices.prices = GetListPrices(nodeTemp); return root; }
public Root CrawlerJetstar(int Adults, string ArrivalCode, int Children, DateTime DepartTime, string DepartureCode, int Inf, bool IsRoundTrip, DateTime ReturnTime) { Root root = null; try { SearchInputService searchInput = new SearchInputService(Adults, ArrivalCode, Children, DepartTime, DepartureCode, Inf, IsRoundTrip, ReturnTime,false); Jetstar jetstar = new Jetstar(); root= jetstar.CreateXmlDocument(searchInput); } catch { } return root; }
public RootTemp CreateXmlDocument(SearchInputService input) { //CookieCollection c= crawlerHelper.getCookieCollection(adress, "POST", getPostData(input)); HtmlDocument d = crawlerHelper.getDocument(address, "POST", getPostData(input), null); RootTemp rootxml = new RootTemp(); rootxml.Departure = input.DepartureCode; rootxml.Arrival = input.ArrivalCode; rootxml.AirLine = AirLineName.tiger; rootxml.blocks = new List<Block>(); rootxml.AirLine = AirLineName.tiger; Block b = new Block(); HtmlNode node = d.DocumentNode.SelectSingleNode("//div[contains(@class,'depart-flight')]"); b.outBound = getOutInBound(node); node = d.DocumentNode.SelectSingleNode("//div[contains(@class,'return-flight')]"); b.inBound = getOutInBound(node); rootxml.blocks.Add(b); return rootxml; }
public string getPostData(SearchInputService myInput) { StringBuilder postData = new StringBuilder(""); string waytype = "RoundTrip"; if (!myInput.IsRoundTrip) waytype = "OneWay"; postData.Append("__EVENTTARGET="); postData.Append("&__EVENTARGUMENT="); postData.Append("&__VIEWSTATE=%2FwEPDwUBMGRk7p3dDtvn3PMYYJ9u4RznKUiVx98%3D"); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24RadioButtonMarketStructure=" + waytype); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24HiddenFieldExternalRateId="); postData.Append("&ControlGroupSearchView_AvailabilitySearchInputSearchVieworiginStation1=" + myInput.DepartureCode); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketOrigin1=" + myInput.DepartureCode); postData.Append("&ControlGroupSearchView_AvailabilitySearchInputSearchViewdestinationStation1=" + myInput.ArrivalCode); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketDestination1=" + myInput.ArrivalCode); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketDay1=" + myInput.DepartTime.ToString("dd")); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketMonth1=" + myInput.DepartTime.ToString("yyyy-MM")); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketDateRange1=1%7C1"); postData.Append("&date_picker=" + myInput.DepartTime.ToString("yyyy-MM-dd")); postData.Append("&pageToken="); if (myInput.IsRoundTrip) { postData.Append("&ControlGroupSearchView_AvailabilitySearchInputSearchVieworiginStation2="); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketOrigin2="); postData.Append("&ControlGroupSearchView_AvailabilitySearchInputSearchViewdestinationStation2="); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketDestination2="); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketDay2=" + myInput.ReturnTime.ToString("dd")); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketMonth2=" + myInput.ReturnTime.ToString("yyyy-MM")); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketDateRange2=1%7C1"); postData.Append("&date_picker=" + myInput.ReturnTime.ToString("yyyy-MM-dd")); } postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListPassengerType_ADT=" + myInput.Adults); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListPassengerType_CHD=" + myInput.Children); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListPassengerType_INFANT=" + myInput.Inf); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24HIDDENPROMOCODE="); postData.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMCCCurrency=default"); postData.Append("&hiddendAdultSelection=" + myInput.Adults); postData.Append("&hiddendChildSelection=" + myInput.Children); postData.Append("&ControlGroupSearchView%24ButtonSubmit=get+flights"); return postData.ToString(); }
public RootTemp CreateXmlDocument(SearchInputService input) { //CookieCollection c= crawlerHelper.getCookieCollection(adress, "POST", getPostData(input)); _input = input; string posdata = getPostData(input); HtmlDocument d = crawlerHelper.getDocument(address, "POST", posdata, null); ////debug //File.WriteAllText("D:p.html", d.DocumentNode.InnerHtml); RootTemp rootxml = new RootTemp(); rootxml.Departure = input.DepartureCode; rootxml.Arrival = input.ArrivalCode; rootxml.blocks = new List<Block>(); rootxml.AirLine = AirLineName.airAsia; Block b = new Block(); HtmlNode node = d.DocumentNode.SelectSingleNode("//div[@id='availabilityInputContent1']/div[@class='depart-section']"); b.outBound = getOutInBound(node,true); node = d.DocumentNode.SelectSingleNode("//div[@id='availabilityInputContent2']/div[@class='depart-section']"); b.inBound = getOutInBound(node,false); rootxml.blocks.Add(b); return rootxml; }
public Root CreateXmlDocument(SearchInputService input) { CrawlerHelper helper = new CrawlerHelper(); Root root = new Root(); root.Departure = input.DepartureCode; root.Arrival = input.ArrivalCode; root.AirLine = AirLineName.jetstar; HtmlDocument htmld = helper.getDocument("http://booknow.jetstar.com/Search.aspx?culture=vi-VN", "POST", getPosData(input), null); //chua 2 bang ve chieu di va ve HtmlNodeCollection collection = htmld.DocumentNode.SelectNodes("//table[@class='domestic']"); #region Depart try { root.outBound = new OutInBound(); List<Item> items = new List<Item>(); HtmlNode nodeDepart = collection[0]; //cac dong chu ban ghi chuyen bay var collectiontr = nodeDepart.SelectNodes("tbody/tr").Where(i => i.Attributes.Count == 0).ToList(); root.outBound.Items = getItems(collectiontr,input); } catch { } #endregion Depart #region Return try { root.inBound = new OutInBound(); HtmlNode nodeReturn = collection[1]; //cac dong chu ban ghi chuyen bay var collectiontr = nodeReturn.SelectNodes("tbody/tr").Where(i => i.Attributes.Count == 0).ToList(); root.inBound.Items = getItems(collectiontr,input); } catch { } #endregion Return return root; }
public Root CrawlerVietNamAirlines(int Adults, string ArrivalCode, int Children, DateTime DepartTime, string DepartureCode, int Inf, bool IsRoundTrip, DateTime ReturnTime) { Root root = null; try { SearchInputService searchInput = new SearchInputService(Adults, ArrivalCode, Children, DepartTime, DepartureCode, Inf, IsRoundTrip, ReturnTime,false); VietnamAirlines vietnamAirlines = new VietnamAirlines(); root= vietnamAirlines.CreateXmlDocument(searchInput); } catch { } return root; }
private string getPostdata2(SearchInputService inputSearchJetstar) { string viewState = "%2FwEPDwULLTE1MzQ1MjI3MzAPZBYCZg9kFg4CCA8QZGQWAGQCCQ8QZGQWAGQCCw8QZGQWAGQCDQ8QZGQWAGQCEQ8QZGQWAGQCEg8QZGQWAGQCEw8QZGQWAGRkDuhQN17CT5ZIydlFFSt%2BWc8NsCA%3D"; StringBuilder postdata = new StringBuilder(""); postdata.Append("__VIEWSTATE=" + viewState); postdata.Append("&" + getPostdata(inputSearchJetstar)); postdata.Append("&SesID="); postdata.Append("&DebugID=71"); return postdata.ToString(); }
private string getPostdata(SearchInputService inputSearchJetstar) { StringBuilder postdata = new StringBuilder(""); if (inputSearchJetstar.IsRoundTrip) { postdata.Append("chkRoundTrip=on"); } else { postdata.Append("chkRoundTrip="); } postdata.Append("&lstOrigAP=" + inputSearchJetstar.DepartureCode); postdata.Append("&lstDestAp=" + inputSearchJetstar.ArrivalCode); postdata.Append("&dlstDepDate_Day=" + inputSearchJetstar.DepartTime.Day); postdata.Append("&dlstDepDate_Month=" + inputSearchJetstar.DepartTime.Year + "%2F" + inputSearchJetstar.DepartTime.Month); postdata.Append("&dlstRetDate_Day=" + inputSearchJetstar.ReturnTime.Day); postdata.Append("&dlstRetDate_Month=" + inputSearchJetstar.ReturnTime.Year + "%2F" + inputSearchJetstar.ReturnTime.Month); postdata.Append("&lstDepDateRange=0"); postdata.Append("&lstRetDateRange=0"); postdata.Append("&txtNumAdults=" + inputSearchJetstar.Adults); postdata.Append("&txtNumChildren=" + inputSearchJetstar.Children); postdata.Append("&txtNumInfants=" + inputSearchJetstar.Inf); postdata.Append("&lstLvlService=1"); postdata.Append("&lstResCurrency=VND"); postdata.Append("&lstCurrency=VND"); postdata.Append("&blnFares=" + inputSearchJetstar.Infare); postdata.Append("&txtPromoCode="); return postdata.ToString(); }
public RootForeign CrawlerVietJetAirForeign(int Adults, string ArrivalCode, int Children, DateTime DepartTime, string DepartureCode, int Inf, bool IsRoundTrip, DateTime ReturnTime) { try { Root root = null; SearchInputService searchInput = new SearchInputService(Adults, ArrivalCode, Children, DepartTime, DepartureCode, Inf, IsRoundTrip, ReturnTime, false); VietJetAir vietJetAir = new VietJetAir(); root = vietJetAir.CreateXmlDocument(searchInput); return root.Convert2RootForeign(searchInput); } catch { } return null; }
private string getPostdata(SearchInputService myInputSearch) { StringBuilder postdata = new StringBuilder(""); postdata.Append("from1=" + myInputSearch.DepartureCode); postdata.Append("&to1=" + myInputSearch.ArrivalCode); postdata.Append("&departureDate1=" + myInputSearch.DepartTime.ToString("yyyy-MM-dd") + "+09%3A01%3A00"); int tripType = 1; if (myInputSearch.IsRoundTrip) { tripType = 2; postdata.Append("&from2=" + myInputSearch.ArrivalCode); postdata.Append("&to2=" + myInputSearch.DepartureCode); postdata.Append("&departureDate2=" + myInputSearch.ReturnTime.ToString("yyyy-MM-dd") + "+09%3A01%3A00"); } postdata.Append("&tripType=" + tripType); postdata.Append("&adult=" + myInputSearch.Adults); postdata.Append("&child=" + myInputSearch.Children); postdata.Append("&infant=" + myInputSearch.Inf); postdata.Append("&student=0"); postdata.Append("&seaman=0"); postdata.Append("&seniorCitizen=0"); postdata.Append("&labour=0"); postdata.Append("&class=Y"); postdata.Append("&flightType=2"); postdata.Append("&prefAirline="); return postdata.ToString(); }
//lay gia chi tiet cua nguoi lon,tre em,tre so sinh va gan vao bien flight private void getPriceDetail(SearchInputService input, HtmlNode nodePrice, FlightForeign flight) { int indexPrice = 1; if (input.Adults > 0) { HtmlNode nodeAdult = nodePrice.SelectSingleNode("tr[" + indexPrice + "]/td[2]"); flight.PriceAdult = decimal.Parse(nodeAdult.InnerText) * MoneyRate.MONEY_RATE; indexPrice++; } if (input.Children > 0) { HtmlNode nodeChildren = nodePrice.SelectSingleNode("tr[" + indexPrice + "]/td[2]"); flight.PriceChild = decimal.Parse(nodeChildren.InnerText) * MoneyRate.MONEY_RATE; indexPrice++; } if (input.Inf > 0) { HtmlNode nodeChildren = nodePrice.SelectSingleNode("tr[" + indexPrice + "]/td[2]"); flight.PriceInfant = decimal.Parse(nodeChildren.InnerText) * MoneyRate.MONEY_RATE; } HtmlNode nodeTaxPrice = nodePrice.SelectSingleNode("tr[last()-1]/td[2]"); flight.TaxPrice = decimal.Parse(nodeTaxPrice.InnerText) * MoneyRate.MONEY_RATE; }
private string getPostData(SearchInputService myInput) { StringBuilder postData = new StringBuilder(""); postData.Append("eventTarget="); postData.Append("&eventArgument="); postData.Append("&viewState=%2FwEPDwUBMGRktapVDbdzjtpmxtfJuRZPDMU9XYk%3D"); postData.Append("&pageToken="); postData.Append("&culture=en-GB"); string waytype = "RoundTrip"; if (!myInput.IsRoundTrip) { waytype = "OneWay"; postData.Append("&oneWayOnly="); } postData.Append("&ControlGroupCompactView%24AvailabilitySearchInputCompactView%24RadioButtonMarketStructure=" + waytype); postData.Append("&ControlGroupCompactView_AvailabilitySearchInputCompactVieworiginStation1=" + myInput.DepartureCode); postData.Append("&ControlGroupCompactView%24AvailabilitySearchInputCompactView%24TextBoxMarketOrigin1=" + myInput.DepartureCode); postData.Append("&ControlGroupCompactView_AvailabilitySearchInputCompactViewdestinationStation1=" + myInput.ArrivalCode); postData.Append("&ControlGroupCompactView%24AvailabilitySearchInputCompactView%24TextBoxMarketDestination1=" + myInput.ArrivalCode); postData.Append("&date_picker=" + myInput.DepartTime.Month + "%2F" + myInput.DepartTime.Day + "%2F" + myInput.DepartTime.Year); postData.Append("&date_picker="); postData.Append("&ControlGroupCompactView%24AvailabilitySearchInputCompactView%24DropDownListMarketDay1=" + myInput.DepartTime.Day); postData.Append("&ControlGroupCompactView%24AvailabilitySearchInputCompactView%24DropDownListMarketMonth1=" + myInput.DepartTime.ToString("yyyy-MM")); postData.Append("&date_picker=" + myInput.ReturnTime.Month + "%2F" + myInput.ReturnTime.Day + "%2F" + myInput.ReturnTime.Year); postData.Append("&date_picker="); postData.Append("&ControlGroupCompactView%24AvailabilitySearchInputCompactView%24DropDownListMarketDay2=" + myInput.ReturnTime.Day); postData.Append("&ControlGroupCompactView%24AvailabilitySearchInputCompactView%24DropDownListMarketMonth2=" + myInput.ReturnTime.ToString("yyyy-MM")); postData.Append("&ControlGroupCompactView%24AvailabilitySearchInputCompactView%24DropDownListPassengerType_ADT=" + myInput.Adults); postData.Append("&ControlGroupCompactView%24AvailabilitySearchInputCompactView%24DropDownListPassengerType_CHD=" + myInput.Children); postData.Append("&ControlGroupCompactView%24AvailabilitySearchInputCompactView%24DropDownListPassengerType_INFANT=" + myInput.Inf); postData.Append("&ControlGroupCompactView%24MultiCurrencyConversionViewCompactSearchView%24DropDownListCurrency=default"); postData.Append("&ControlGroupCompactView%24AvailabilitySearchInputCompactView%24DropDownListSearchBy=columnView"); postData.Append("&ControlGroupCompactView%24ButtonSubmit=Search"); postData.Append("&__EVENTTARGET="); postData.Append("&__EVENTARGUMENT="); postData.Append("&__VIEWSTATE=%2FwEPDwUBMGRktapVDbdzjtpmxtfJuRZPDMU9XYk%3D"); return postData.ToString(); }
private string getPosData(SearchInputService inputSearchJetstar) { StringBuilder postdata = new StringBuilder(""); postdata.Append("__VIEWSTATE=%2FwEPDwUBMGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFJ01lbWJlckxvZ2luU2VhcmNoVmlldyRtZW1iZXJfUmVtZW1iZXJtZSDCMtVG%2F1lYc7dy4fVekQjBMvD5"); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListCurrency=VND"); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListFareTypes=I"); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketDay1=" + inputSearchJetstar.DepartTime.Day); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketDay2=" + inputSearchJetstar.ReturnTime.Day); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketDay3="); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketMonth1=" + inputSearchJetstar.DepartTime.Year + "-" + inputSearchJetstar.DepartTime.Month); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketMonth2=" + inputSearchJetstar.ReturnTime.Year + "-" + inputSearchJetstar.ReturnTime.Month); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListMarketMonth3="); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListPassengerType_ADT=" + inputSearchJetstar.Adults); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListPassengerType_CHD=" + inputSearchJetstar.Children); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24DropDownListPassengerType_INFANT=" + inputSearchJetstar.Inf); string type = ""; if (inputSearchJetstar.IsRoundTrip) { type = "RoundTrip"; } else { type = "OneWay"; } postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24RadioButtonMarketStructure=" + type); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketDestination1=" + inputSearchJetstar.ArrivalCode); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketDestination2=" + inputSearchJetstar.DepartureCode); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketDestination3"); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketOrigin1=" + inputSearchJetstar.DepartureCode); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketOrigin2=" + inputSearchJetstar.ArrivalCode); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24TextBoxMarketOrigin3="); postdata.Append("&ControlGroupSearchView%24ButtonSubmit="); postdata.Append("&culture=vi-VN"); postdata.Append("&date_picker="); postdata.Append("&go-booking="); postdata.Append("&pageToken:sLkmnwXwAsY="); postdata.Append("&ControlGroupSearchView%24AvailabilitySearchInputSearchView%24fromCS=yes"); return postdata.ToString(); }
private List<Item> getitems(DateTime datetime,SearchInputService input, HtmlNodeCollection collection) { List<Item> items = new List<Item>(); if (collection == null) return items; foreach (HtmlNode node in collection) { HtmlNodeCollection collectionRecord = node.SelectNodes("td"); try { Item item = new Item(); HtmlNode node1; HtmlNodeCollection colectionTimeNo = collectionRecord.ElementAt(0).SelectNodes("table/tr[1]/td"); node1 = colectionTimeNo.ElementAt(0); string departureTime = node1.InnerHtml.Replace(" ", " ").Replace("<br>", " ").Split(' ')[0]; item.departureTime = DateTimeHelper.getDate(datetime, departureTime); node1 = colectionTimeNo.ElementAt(1); string arriveTime = node1.InnerHtml.Replace(" ", " ").Replace("<br>", " ").Split(' ')[0]; item.arriveTime = DateTimeHelper.getDate(datetime, arriveTime); //kiem tra lai thoi gian den DateTime timeTemp = DateTime.Parse(item.arriveTime); if (timeTemp.Hour < DateTime.Parse(item.departureTime).Hour) { item.arriveTime = timeTemp.AddDays(1).ToString(); } node1 = colectionTimeNo.ElementAt(2); item.flightNo = node1.SelectSingleNode("span").InnerText; HtmlNodeCollection colectionPrice = collectionRecord.ElementAt(1).SelectNodes("table/tr[1]/td"); Price p; item.price = new List<Price>(); try { p = new Price { name = "Promo", price = WebUtility.HtmlDecode(colectionPrice.ElementAt(0).InnerText.Trim()).Replace(",", ""), taxPrice = colectionPrice.ElementAt(0).SelectSingleNode("input[@id='charges']").Attributes["value"].Value.Replace(",", "") }; decimal.Parse(p.price); item.price.Add(p); } catch { } try { p = new Price { name = "Eco", price = WebUtility.HtmlDecode(colectionPrice.ElementAt(1).InnerText.Trim()).Replace(",", ""), taxPrice = colectionPrice.ElementAt(1).SelectSingleNode("input[@id='charges']").Attributes["value"].Value.Replace(",", "") }; decimal.Parse(p.price); item.price.Add(p); } catch { } try { p = new Price { name = "Deluxe", price = WebUtility.HtmlDecode(colectionPrice.ElementAt(2).InnerText.Trim()).Replace(",", ""), taxPrice = colectionPrice.ElementAt(2).SelectSingleNode("input[@id='charges']").Attributes["value"].Value.Replace(",", "") }; decimal.Parse(p.price); item.price.Add(p); } catch { } if (item.price != null && item.price.Count > 0) items.Add(item); } catch { } } return items; }
public RootMinPrice GetPriceInFareJetstar(int Adults, string ArrivalCode, int Children, DateTime DepartTime, string DepartureCode, int Inf, bool IsRoundTrip, DateTime ReturnTime) { SearchInputService searchInput = new SearchInputService(Adults, ArrivalCode, Children, DepartTime, DepartureCode, Inf, IsRoundTrip, ReturnTime, true); Jetstar jetstar = new Jetstar(); return jetstar.GetPriceInFare(searchInput); }
public RootMinPrice GetPriceInFareVietNamAirlines(int Adults, string ArrivalCode, int Children, DateTime DepartTime, string DepartureCode, int Inf, bool IsRoundTrip, DateTime ReturnTime) { SearchInputService searchInput = new SearchInputService(Adults, ArrivalCode, Children, DepartTime, DepartureCode, Inf, IsRoundTrip, ReturnTime, true); VietnamAirlines vietnamAirlines = new VietnamAirlines(); return vietnamAirlines.GetPriceInFare(searchInput); }
private List<Item> getItems(List<HtmlNode> collectiontr,SearchInputService input) { List<Item> items = new List<Item>(); foreach (HtmlNode nodetr in collectiontr) { HtmlNodeCollection collectiontd = nodetr.SelectNodes("td"); HtmlNode node1; Item item = new Item(); node1 = collectiontd.ElementAt(0).SelectSingleNode("strong"); item.departureTime = DateTimeHelper.getDate(input.DepartTime, node1.InnerText); node1 = collectiontd.ElementAt(1).SelectSingleNode("strong"); item.arriveTime = DateTimeHelper.getDate(input.DepartTime, node1.InnerText); node1 = collectiontd.ElementAt(3).SelectSingleNode("div[1]/label"); List<Price> prices = new List<Price>(); prices.Add(new Price { name = "", price = node1.InnerText.Replace("VND ", "").Replace(",", "") }); node1 = collectiontd.ElementAt(2).SelectSingleNode("div/div[1]//span[@class='flight-no']"); item.flightNo = node1.InnerText; items.Add(item); item.price = prices; } return items; }