예제 #1
0
        public async Task <List <OlimpLeague> > GetLeagues()
        {
            List <OlimpLeague> resultLeagues = new List <OlimpLeague>();
            string             url           = "/en/sports/champs/football-betting";

            HtmlNode documentNode = this.GetDocumentNodeByUrl(url);

            if (documentNode != null)
            {
                HtmlNode leaguesDiv = documentNode.QuerySelector("div.sport_matches:nth-child(1)");

                foreach (HtmlNode leagueNode in leaguesDiv.ChildNodes)
                {
                    if (leagueNode.OriginalName == "div" && this.GetAtributeValueByName(leagueNode, "class") == "s_m_item")
                    {
                        try
                        {
                            foreach (HtmlNode node in leagueNode.ChildNodes)
                            {
                                if (node.OriginalName == "div" && this.GetAtributeValueByName(node, "class") == "s_m_i_name")
                                {
                                    OlimpLeague olimpLeague = new OlimpLeague();
                                    olimpLeague.Name = node.ChildNodes[1].InnerText;
                                    olimpLeague.Href = this.GetAtributeValueByName(node.ChildNodes[1], "href");
                                    olimpLeague.Id   = this.GetLeagueId(olimpLeague.Href);

                                    if (olimpLeague.Name.Contains("Special offers") == true || olimpLeague.Name.Contains("Outrights") == true || olimpLeague.Name.Contains("Statistics") || olimpLeague.Name.Contains("Draw") == true)
                                    {
                                        continue;
                                    }


                                    resultLeagues.Add(olimpLeague);
                                }
                            }
                        }

                        catch (Exception ex)
                        {
                            continue;
                        }
                    }
                }
            }

            else
            {
                return(null);
            }

            return(resultLeagues);
        }
예제 #2
0
        public async Task <List <OlimpEvent> > GetEventsByLeague(OlimpLeague league)
        {
            List <OlimpEvent> events = new List <OlimpEvent>();
            string            url    = league.Href;


            HtmlNode documentNode = this.GetDocumentNodeByUrl(url);

            if (documentNode != null)
            {
                try
                {
                    HtmlNode eventsDiv = documentNode.QuerySelector(".to_header");

                    HtmlNodeCollection nodes = eventsDiv.ChildNodes;

                    for (int i = 0; i < nodes.Count; i++)
                    {
                        if (nodes[i].OriginalName == "div" && this.GetAtributeValueByName(nodes[i], "data-id") == league.Id)
                        {
                            HtmlNode chListNode = nodes[i + 2];


                            foreach (HtmlNode node in chListNode.ChildNodes)
                            {
                                if (node.OriginalName == "div" && this.GetAtributeValueByName(node, "class") == "ch_line")
                                {
                                    OlimpEvent olimpEvent = this.GetOlimpEventByNode(node);
                                    olimpEvent.LeagueName = league.Name;
                                    olimpEvent.Dateadded  = DateTime.Now.ToString();


                                    events.Add(olimpEvent);
                                }
                            }
                        }
                    }
                }

                catch (Exception ex)
                {
                    return(null);
                }
            }

            else
            {
                return(null);
            }

            return(events);
        }