Ejemplo n.º 1
0
 public Paper(string id, string titel, int number, Print print)
 {
     this.Title = titel;
     this.Id = id;
     this.Number = number;
     this.Print = print;
 }
        public static List<Paper> LoadArticles(Print print)
        {
            using (var client = new WebClient { Encoding = Encoding.UTF8 })
            {
                var str = client.DownloadString(print.Uri);
                const string pattern = @"<a\s.*href=""onlinearticle(?<id>\d{4}).aspx"">(?<titel>.*)</a>";
                var counter = 1;
                var result = (Regex.Matches(str, pattern)
                    .Cast<Match>()
                    .Select(m => new Paper(m.Groups["id"].Value, m.Groups["titel"].Value, counter++, print)));

                return new List<Paper>(result);
            }
        }