Ejemplo n.º 1
0
        static List<Station> GetStations(List<HtmlNode> rows)
        {
            var tempStations = new List<Station>();

            for (var i = 2; i < rows.Count - 1; i++)
            {
                var link = "";
                var d = rows[i].Descendants("td").FirstOrDefault();
                var a = d.Descendants("a");

                if (a != null && a.Count() > 0)
                {
                    link = rows[i].Descendants("td")
                                  .FirstOrDefault()
                                  .Descendants("a")
                                  .FirstOrDefault()
                                  .Attributes
                                  .First()
                                  .Value;
                }

                var stationItem = new Station
                {
                    Name = GetStationName(rows[i]),
                    Link = link,
                    IsRegullar = IsRegullarStation(rows[i])
                };

                if (!string.IsNullOrEmpty(stationItem.Name))
                {
                    tempStations.Add(stationItem);
                }
            }

            tempStations.Add(GetLastStation(rows));

            return tempStations;
        }
Ejemplo n.º 2
0
        static Station GetLastStation(List<HtmlNode> rows)
        {
            var lastStation = new Station
            {
                Name = rows[rows.Count - 1].Descendants("td").FirstOrDefault().InnerText.Replace("&nbsp;", string.Empty)
            };

            return lastStation;
        }