public TrainInformation GetTrain(List<Station> stationList) { string Url1 = "https://kyfw.12306.cn/otn/czxx/queryByTrainNo?train_no=" + trainNo + "&from_station_telecode=" + fromStationCode + "&to_station_telecode=" + toStationCode + "&depart_date=" + Date; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url1); req.Method = "GET"; System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => { return true; }; HttpWebResponse res = (HttpWebResponse)req.GetResponse(); Stream resst = res.GetResponseStream(); StreamReader sr = new StreamReader(resst); string str = sr.ReadToEnd(); List<String> stationNameList = new List<string>(); JSON GetName = new JSON("station_name"); for (; ; ) { } }
public TrainInformation(string str) { List<JSON> result = new List<JSON>(); JSON json1 = new JSON("station_train_code"); result.Add(json1); json1 = new JSON("from_station_name"); result.Add(json1); json1 = new JSON("to_station_name"); result.Add(json1); json1 = new JSON("start_time"); result.Add(json1); json1 = new JSON("arrive_time"); result.Add(json1); json1 = new JSON("day_difference"); result.Add(json1); json1 = new JSON("lishi"); result.Add(json1); json1 = new JSON("from_station_no"); result.Add(json1); json1 = new JSON("to_station_no"); result.Add(json1); json1 = new JSON("swz_num"); result.Add(json1); json1 = new JSON("tz_num"); result.Add(json1); json1 = new JSON("zy_num"); result.Add(json1); json1 = new JSON("ze_num"); result.Add(json1); json1 = new JSON("gr_num"); result.Add(json1); json1 = new JSON("rw_num"); result.Add(json1); json1 = new JSON("yw_num"); result.Add(json1); json1 = new JSON("rz_num"); result.Add(json1); json1 = new JSON("yz_num"); result.Add(json1); json1 = new JSON("wz_num"); result.Add(json1); json1 = new JSON("qt_num"); result.Add(json1); json1 = new JSON("train_no"); result.Add(json1); for (int i = 0; i < result.Count; i++) { result[i].getValue(str); switch (i) { case 0: this.trainCode = result[i].Value; break; case 1: this.fromStationName = result[i].Value; break; case 2: this.toStationName = result[i].Value; break; case 3: this.startTime = result[i].Value; break; case 4: this.arriveTime = result[i].Value; break; case 5: this.dayDifference = result[i].Value; break; case 6: this.spendTime = result[i].Value; break; case 7: this.fromStationNo = result[i].Value; break; case 8: this.toStationNo = result[i].Value; break; case 9: this.BusinessTicket = result[i].Value; break; case 10: this.TopGradeTicket = result[i].Value; break; case 11: this.FirstClassTicket = result[i].Value; break; case 12: this.SecondClassTicket = result[i].Value; break; case 13: this.AdvancedSoftSleeperTicket = result[i].Value; break; case 14: this.SoftSleeperTicket = result[i].Value; break; case 15: this.HardSleeperTicket = result[i].Value; break; case 16: this.SoftSeatTicket = result[i].Value; break; case 17: this.HardSeatTicket = result[i].Value; break; case 18: this.NoneSeatTicket = result[i].Value; break; case 19: this.Other = result[i].Value; break; default: this.trainNo = result[i].Value; break; } } }