Ejemplo n.º 1
0
        /// <summary>
        /// Получить коэф, тотал, более/менее о матче
        /// </summary>
        /// <param name="match">Матч о котором нужно получить информацию</param>
        /// <returns></returns>
        public async Task <string> GetPageCoefficient(MatchModels match)
        {
            FlurlClient client = new FlurlClient();

            client.Headers.Add("Accept", "*/*");
            client.Headers.Add("x-geoip", "1");
            client.Headers.Add("x-fsign", _xFSign);
            client.Headers.Add("accept-language", "*");
            client.Headers.Add("x-requested-with", "XMLHttpRequest");
            client.Headers.Add("x-referer", "https://www.FlashScore.com.ua/match/" + match.Id + "/#odds-comparison;over-under;full-time");
            client.Headers.Add("accept-encoding", "gzip, deflate, br");

            string response = await client.Request("https://d.FlashScore.com.ua/x/feed/" + "d_od_" + match.Id + "_ru_1_eu").GetStringAsync();

            return(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Получить информацию конкретно о матче
        /// </summary>
        /// <param name="match"></param>
        /// <returns></returns>
        public async Task <MatchModels> GetMatchInfoAsync(MatchModels match)
        {
            FlurlClient client = new FlurlClient();

            client.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
            client.Headers.Add("Accept-Encoding", "gzip, deflate");
            client.Headers.Add("Accept-Language", "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,af;q=0.6");
            client.Headers.Add("Cache-Control", "max-age=0");
            client.Headers.Add("Host", "www.FlashScore.com.ua");
            client.Headers.Add("Upgrade-Insecure-Requests", "1");

            string response = await client.Request(match.Link + "#odds-comparison;over-under;full-time").GetStringAsync();

            MatchModels mim = Parsing.MatchInfo(response.ToString());

            return(mim);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Спарсить информацию о матчей
        /// </summary>
        /// <param name="response">исходный код страницы</param>
        /// <returns></returns>
        public static MatchModels MatchInfo(string response)
        {
            MatchModels matchInfo = new MatchModels();

            HtmlParser hp       = new HtmlParser();
            var        document = hp.Parse(response);

            matchInfo.Match.Command1.Name = document.QuerySelectorAll(".participant-imglink>img")[0].GetAttribute("alt");
            matchInfo.Match.Command2.Name = document.QuerySelectorAll(".participant-imglink>img")[1].GetAttribute("alt");

            if (document.QuerySelectorAll("span.scoreboard").Count() > 0)
            {
                matchInfo.Match.Command1.Goal = int.Parse(document.QuerySelectorAll(".scoreboard")[0].TextContent);
                matchInfo.Match.Command2.Goal = int.Parse(document.QuerySelectorAll(".scoreboard")[1].TextContent);
            }
            matchInfo.Match.Country = document.QuerySelector(".description__country").FirstChild.TextContent.Replace(": ", "");
            matchInfo.Match.Liga    = document.QuerySelector(".description__country>a").TextContent;

            var tts = document.QuerySelector("#utime").TextContent;

            try
            {
                var date = DateTime.Parse(document.QuerySelector("#utime").TextContent);
                matchInfo.Match.DateStart = date;
            }
            catch (FormatException)
            {
                matchInfo.Match.DateStart = null;
            }

            var resultMatch = document.QuerySelector(".info-status.mstat").TextContent.Trim();

            if (resultMatch == None)
            {
                matchInfo.Result = Enums.ResultMatch.None;
            }
            if (resultMatch == Completed)
            {
                matchInfo.Result = Enums.ResultMatch.Completed;
            }
            if (resultMatch == Canceled)
            {
                matchInfo.Result = Enums.ResultMatch.Calceled;
            }
            if (resultMatch == Absence)
            {
                matchInfo.Result = Enums.ResultMatch.Absence;
            }
            if (resultMatch == SeriesOfPinal)
            {
                matchInfo.Result = Enums.ResultMatch.SeriesOfPinal;
            }
            if (resultMatch == Moved)
            {
                matchInfo.Result = Enums.ResultMatch.Moved;
            }
            if (resultMatch == TechDefeat)
            {
                matchInfo.Result = Enums.ResultMatch.TechDefeat;
            }
            if (resultMatch == AfterExtraTime)
            {
                matchInfo.Result = Enums.ResultMatch.AfterExtraTime;
            }

            return(matchInfo);
        }