Esempio n. 1
0
        private void ParseMusicStagePage(MusicShowInstance showinstance, Dispatcher dispatcher)
        {
            var page = new HtmlWeb().Load(showinstance.URL);

            for (var stagetypenode = page.DocumentNode.SelectSingleNode("//h2[@id='wiki_lineup']/following-sibling::h3[not(preceding-sibling::h2[@id='wiki_winner'])]"); stagetypenode != null;
                 stagetypenode = stagetypenode.SelectSingleNode("./following-sibling::h3[not(preceding-sibling::h2[@id='wiki_winner'])]"))
            {
                var stagetype = new MusicShowInstanceStageType(dispatcher)
                {
                    StageTypeName = stagetypenode.InnerText
                };
                stagetype.Columns.AddRange(stagetypenode.SelectNodes(@"./following-sibling::table[1]/thead/tr/th").Skip(2).Select(e => e.InnerText));

                foreach (var stagetypeelem in stagetypenode.SelectNodes(@"./following-sibling::table[1]/tbody/tr"))
                {
                    var stage = new MusicShowStage(dispatcher)
                    {
                        GroupName = stagetypeelem.Descendants("td").First().InnerText,
                        SongName  = stagetypeelem.Descendants("td").ElementAt(1).InnerText,
                    };
                    stage.Links.AddRange(stagetypeelem.Descendants("td").Skip(2).Select(e => e.InnerHtml));
                    stagetype.Stages.Add(stage);
                }

                showinstance.StageTypes.Add(stagetype);
            }
        }
Esempio n. 2
0
        private void ParseMusicShowPage(MusicShow show, Dispatcher dispatcher)
        {
            var page = new HtmlWeb().Load(show.URL);

            for (var node = page.DocumentNode.SelectSingleNode("//h2[@id='wiki_archive']/following-sibling::p");
                 int.TryParse(node.InnerText, out var tmpint); node = node.SelectSingleNode("./following-sibling::p"))
            {
                foreach (var stageelem in node.SelectNodes(@"./following-sibling::table[1]/tbody/tr/td[1]/a"))
                {
                    var showinstance = new MusicShowInstance(dispatcher)
                    {
                        Date      = DateTime.ParseExact(stageelem.InnerText, "yyyyMMdd", CultureInfo.InvariantCulture),
                        URL       = "https://www.reddit.com" + stageelem.GetAttributeValue("href", null),
                        MusicShow = show,
                    };
                    show.Instances.Add(showinstance);
                    MusicShowInstances.Add(showinstance);
                    Task.Factory.StartNew(() => ParseMusicStagePage(showinstance, dispatcher));
                }
            }
        }