Example #1
0
 public SportEvent(EventInfo info, CoefSet coefs)
 {
     this.Info = info;
     this.Coefs = coefs;
 }
Example #2
0
        public void Refresh()
        {
            this.events = new List<SportEvent>();
            var webGet = new HtmlWeb();
            var footballPage = webGet.Load(@"https://www.marathonbet.co.uk/su/popular/Football/");
            var eventsInfoNodes = footballPage.DocumentNode.SelectNodes("//div[@class='block-events-head ']//a[@class='hover-underline block']");
            var teamInfo = footballPage.DocumentNode.SelectNodes("//table[@class='foot-market']");
            var eventInfo = new EventInfo();
            var coefSet = new CoefSet { BetsName = "Marafon" };
            foreach (var eventInfoSplit in eventsInfoNodes.Select(eventInfoNode => eventInfoNode.InnerText.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries)))
            {
                eventInfo.TypeSport = eventInfoSplit[0];
                for (var i = 0; i < eventInfoSplit.Count(); i++)
                {
                    eventInfo.Info += eventInfoSplit[i];
                }

                foreach (var table in teamInfo)
                {
                    var body = table.ChildNodes.Where(x => x.Name == "tbody");
                    var i = 0;
                    foreach (var htmlNode in body)
                    {
                        var teamSplit = htmlNode.Attributes["data-event-name"].Value.Split(
                            new[] { " - " },
                            StringSplitOptions.RemoveEmptyEntries);

                        eventInfo.FirstTeam = teamSplit[0];
                        eventInfo.SecondTeam = teamSplit[1];

                        var eventDate = htmlNode.SelectNodes("//td[@class='date']")[i].InnerText;
                        eventInfo.Date = ParseDate(eventDate);
                        i++;
                        var trs = htmlNode.SelectNodes("//tr[@class='event-header']");
                        foreach (var coefs in trs.Select(tr => tr.SelectNodes("td/span")))
                        {
                            coefSet.FirstWin = ParseDecimal(coefs[0].InnerText);
                            coefSet.DrawnGame = ParseDecimal(coefs[1].InnerText);
                            coefSet.SecondWin = ParseDecimal(coefs[2].InnerText);
                            coefSet.FirstWinOrDrawnGame = ParseDecimal(coefs[3].InnerText);
                            coefSet.FirstWinOrSecondWin = ParseDecimal(coefs[4].InnerText);
                            coefSet.SecondWinOrDrawnGame = ParseDecimal(coefs[5].InnerText);
                            coefSet.FirstFora = ParseCoefAndGoals(coefs[6].ParentNode.InnerText);
                            coefSet.SecondFora = ParseCoefAndGoals(coefs[7].ParentNode.InnerText);
                            coefSet.Less = ParseCoefAndGoals(coefs[8].ParentNode.InnerText);
                            coefSet.Larger = ParseCoefAndGoals(coefs[9].ParentNode.InnerText);
                        }

                        var sportEvent = new SportEvent(eventInfo, coefSet);
                        this.events.Add(sportEvent);
                    }
                }
            }
        }