Exemplo n.º 1
0
        public JsonResult GetNews()
        {
            try
            {
                _sportPageViewModel = new SportPageViewModel();

                //Football news
                _externalUrl = "https://www.fotbollskanalen.se/senaste/";
                GetHtmlDataFromExternalUrl();
                _node = _htmlDoc.DocumentNode.SelectNodes("//div[@class='main-content']").First();
                _sportPageViewModel.FootballNews = HttpUtility.HtmlDecode(_node.OuterHtml);

                return(Json(_sportPageViewModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public JsonResult GetStandings()
        {
            try
            {
                _sportPageViewModel = new SportPageViewModel();

                //PremierLeagueTable
                _externalUrl = "https://www.fotbollskanalen.se/premier-league/?tab=tables";
                GetHtmlDataFromExternalUrl();
                _node = _htmlDoc.DocumentNode.SelectNodes("//div[@class='league-tables']").First();
                //var a = _node.SelectNodes(".//a");
                if (_node != null && _node.OuterHtml != null)
                {
                    _sportPageViewModel.PremierLeagueHtmlTable = HttpUtility.HtmlDecode(_node.OuterHtml);
                }

                //PremierLeagueBestGoalScorersHtmlTable
                _node = _htmlDoc.DocumentNode.SelectNodes("//div[@id='top-scorer']")?.First();
                if (_node != null && _node.OuterHtml != null)
                {
                    _sportPageViewModel.PremierLeagueBestGoalScorersHtmlTable = HttpUtility.HtmlDecode(_node.OuterHtml);
                }

                //AllsvenskanLeagueTable
                _externalUrl = "https://www.fotbollskanalen.se/allsvenskan/?tab=tables";
                GetHtmlDataFromExternalUrl();
                _node = _htmlDoc.DocumentNode.SelectNodes("//div[@class='league-tables']")?.First();
                if (_node != null && _node.OuterHtml != null)
                {
                    _sportPageViewModel.AllsvenskanHtmlTable = HttpUtility.HtmlDecode(_node.OuterHtml);
                }

                //AllsvenskanBestGoalScorersHtmlTable
                _node = _htmlDoc.DocumentNode.SelectNodes("//div[@id='top-scorer']")?.First();
                if (_node != null && _node.OuterHtml != null)
                {
                    _sportPageViewModel.AllsvenskanBestGoalScorersHtmlTable = HttpUtility.HtmlDecode(_node.OuterHtml);
                }

                //LaLigaTable
                _externalUrl = "https://www.fotbollskanalen.se/la-liga/?tab=tables";
                GetHtmlDataFromExternalUrl();
                _node = _htmlDoc.DocumentNode.SelectNodes("//div[@class='league-tables']")?.First();
                if (_node != null && _node.OuterHtml != null)
                {
                    _sportPageViewModel.LaLigaHtmlTable = HttpUtility.HtmlDecode(_node.OuterHtml);
                }

                //LaLigaBestGoalScorersHtmlTable
                _node = _htmlDoc.DocumentNode.SelectNodes("//div[@id='top-scorer']")?.First();
                if (_node != null && _node.OuterHtml != null)
                {
                    _sportPageViewModel.LaLigaBestGoalScorersHtmlTable = HttpUtility.HtmlDecode(_node.OuterHtml);
                }

                //BundesLigaTable
                _externalUrl = "https://www.fotbollskanalen.se/bundesliga/?tab=tables";
                GetHtmlDataFromExternalUrl();
                _node = _htmlDoc.DocumentNode.SelectNodes("//div[@class='league-tables']")?.First();
                if (_node != null && _node.OuterHtml != null)
                {
                    _sportPageViewModel.BundesLigaHtmlTable = HttpUtility.HtmlDecode(_node.OuterHtml);
                }

                //LaLigaBestGoalScorersHtmlTable
                _node = _htmlDoc.DocumentNode.SelectNodes("//div[@id='top-scorer']")?.First();
                if (_node != null && _node.OuterHtml != null)
                {
                    _sportPageViewModel.BundesLigaBestGoalScorersHtmlTable = HttpUtility.HtmlDecode(_node.OuterHtml);
                }

                return(Json(_sportPageViewModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(null);
                //throw ex;
            }
        }