Exemple #1
0
        private void GetEarliestMeeting(string targetUrl, ref string earliestUrl, ref string latestUrl)
        {
            HtmlWeb            web = new HtmlWeb();
            HtmlDocument       doc = web.Load(targetUrl);
            HtmlNodeCollection councilMeetingUrlNodes = doc.DocumentNode.SelectNodes("//div[@class='EventDayScroll']//a[contains(@href,'ModuleID')]");

            if (councilMeetingUrlNodes != null)
            {
                earliestUrl = councilMeetingUrlNodes.FirstOrDefault().Attributes["href"].Value;
                latestUrl   = councilMeetingUrlNodes.LastOrDefault().Attributes["href"].Value;
            }
        }
Exemple #2
0
        public IDictionary <string, CSoccerGameUpdate> ParseGameList(HtmlDocument doc, DateTime date)
        {
            var gamesDictionary = new Dictionary <string, CSoccerGameUpdate>();

            var rawGames = doc.DocumentNode.SelectNodes("//tr[contains(@class,'match')]/.");

            foreach (var rawGame in rawGames)
            {
                try
                {
                    CSoccerGameUpdate game = ParseBasicGameDetails(rawGame, date);
                    if (game != null)
                    {
                        string gameUri = ParseGameUri(rawGame);

                        string leaguePath = new StringBuilder().Append(rawGame.XPath).Append("/preceding-sibling::tr[contains(@class,'round-head') or contains(@class,'group-head')]").ToString();
                        string midComp    = string.Empty;

                        if (!string.IsNullOrEmpty(gameUri) && !gamesDictionary.ContainsKey(gameUri))
                        {
                            HtmlNodeCollection leagueParent = null;
                            try
                            {
                                leagueParent = rawGame.SelectNodes(leaguePath);
                            }
                            catch (Exception ex)
                            {
                            }
                            if (leagueParent != null)
                            {
                                HtmlNode midCompNode = leagueParent.LastOrDefault();
                                if (midCompNode.Attributes["class"].Value.Contains("round-head"))
                                {
                                    midComp = ExtractMidCompetitionName(midCompNode);
                                }
                            }
                            game.Competition.Value = midComp;
                            gamesDictionary.Add(gameUri, game);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }

            return(gamesDictionary);
        }
        public override string GetPreviousSite()
        {
            string       sUrl    = string.Empty;
            string       sResult = CrawlSite();
            HtmlDocument oDoc    = new HtmlDocument();

            oDoc.LoadHtml(sResult);

            if (oDoc.DocumentNode != null)
            {
                HtmlNodeCollection lNodes = oDoc.DocumentNode.SelectNodes("//a[@class='blue' and name(parent::*)='div']");
                HtmlNode           oNode  = lNodes.LastOrDefault(x => x.InnerText.Equals("Previous") && x.Attributes.Any(y => y.Name.Equals("href") && y.Value.Contains("chapter")));
                HtmlAttribute      oAttr  = oNode.Attributes.FirstOrDefault(x => x.Name.Equals("href"));

                if (oAttr != null)
                {
                    sUrl = oAttr.Value;
                }
            }

            return(sUrl);
        }