Ejemplo n.º 1
0
        private void ParseCurrentLives()
        {
            WebClient wb = new WebClient();

            wb.Encoding = Encoding.UTF8;
            var respone = wb.DownloadString($"{url}/su/live/popular");
            var parser  = new HtmlParser();
            var doc     = parser.Parse(respone);

            var mainContainer = doc.GetElementById("container_AVAILABLE");

            foreach (IElement child in mainContainer.Children)
            {
                if (child.ChildElementCount < 2)
                {
                    continue;
                }

                foreach (IElement liga in child.Children[1].Children)
                {
                    if (liga.ChildElementCount == 0)
                    {
                        continue;
                    }
                    if (liga.Children[1].ChildElementCount == 0)
                    {
                        continue;
                    }

                    foreach (IElement ev in liga.Children[1].Children)
                    {
                        string[] teams;
                        SiteRow  rw = new SiteRow();
                        rw.Site = ParserType.Marafon;
                        try
                        {
                            rw.Sport  = child.Children[0].TextContent.Trim();
                            rw.Groupe = liga.Children[0].TextContent.Trim();
                            rw.Match  = ev.Children[2].TextContent.Replace(" @ ", " - ").Trim();
                            teams     = rw.Match.Replace(" - ", "|").Split('|');
                            if (teams.Length != 2)
                            {
                                continue;
                            }
                            rw.TeamName = teams[0];
                        }
                        catch
                        {
                            continue;
                        }

                        _rezult.Add(rw);

                        var rw1 = rw.Clone();
                        rw1.TeamName = teams[1];
                        _rezult.Add(rw1);
                    }
                }
            }
        }
        private List <SiteRow> ParsePage(string link, string Groupe)
        {
            List <SiteRow> rezult = new List <SiteRow>();

            WebClient wb = new WebClient();

            wb.Encoding = Encoding.UTF8;
            var          respone = wb.DownloadString("https://olimp.com/" + link);
            HtmlDocument doc     = new HtmlDocument();

            doc.LoadHtml(respone);

            var trs = doc.DocumentNode.SelectNodes("//tr[@class=\"hi\"]");

            if (trs == null)
            {
                //если нету в этой части ставок
                return(new List <SiteRow>());
            }
            foreach (var tr in trs)
            {
                if (tr.ChildNodes[3].Attributes["width"] == null)
                {
                    continue;
                }

                SiteRow sr = new SiteRow();
                sr.TimeStart = DateTime.Parse(tr.ChildNodes[1].InnerText);
                sr.Groupe    = Groupe;
                sr.Site      = Shared.Enums.ParserType.Olimp;


                string[] teams = tr.ChildNodes[3].InnerText.Trim().Replace(" - ", "|").Split('|');
                if (teams.Length != 2)
                {
                    continue;
                }
                sr.TeamName = teams[0].Trim();

                rezult.Add(sr);

                var sr1 = sr.Clone();
                sr1.TeamName = teams[1].Trim();

                rezult.Add(sr1);
            }


            return(rezult);
        }
        public List <SiteRow> ParseAnonsLive()
        {
            var rezult = new List <SiteRow>();

            WebClient wb = new WebClient();

            wb.Encoding = Encoding.UTF8;
            var          respone = wb.DownloadString($"{url}/betting");
            HtmlDocument doc     = new HtmlDocument();

            doc.LoadHtml(respone);
            var rows = doc.DocumentNode.SelectNodes("//tr").Where(x => x.Id != null && x.Id.Contains("t") && x.Id.ToString().Count() <= 4).ToList();

            foreach (var row in rows)
            {
                int i = 3;
                var x = row.ChildNodes[1].ChildNodes.Count;
                if (x != 5)
                {
                    i = 5;
                }


                var rw = new SiteRow();
                rw.Site  = Shared.Enums.ParserType.Olimp;
                rw.Sport = row.ChildNodes[1].ChildNodes[3].InnerText.Split('.').First().Trim();
                var teams = row.ChildNodes[1].ChildNodes[3].InnerText.Replace(rw.Sport + ". ", "").Replace(" - ", "|").Split('|');
                rw.TimeStart = DateTime.Parse(row.ChildNodes[1].ChildNodes[8].ChildNodes[0].InnerText.Replace("Начало ", "").Trim());
                rw.TeamName  = teams[0];
                rw.Groupe    = "";

                rw.Match = $"{rw.TeamName} - {teams[1]}";
                rezult.Add(rw);

                var rw1 = rw.Clone();
                rw1.TeamName = teams[1];
                rezult.Add(rw1);
            }

            //Получаем Live
            var uri = new Uri(url).Host;

            respone = wb.DownloadString($"http://olimpapi.cc/api/v3/app_api_index.php?action=slice&live=1&time_shift=0&lang_id=0&platforma=site-api&_=0");

            var json = JObject.Parse(respone);

            if (json["data"] != null)
            {
                foreach (JToken token in json["data"])
                {
                    if (token["cn"].ToString().Contains("Статистика"))
                    {
                        continue;
                    }

                    foreach (JToken ev in token["it"])
                    {
                        var rw = new SiteRow();
                        rw.Site      = Shared.Enums.ParserType.Olimp;
                        rw.Sport     = token["sn"].ToString();
                        rw.Groupe    = "";
                        rw.TeamName  = ev["c1"].ToString();
                        rw.Match     = ev["n"].ToString();
                        rw.TimeStart = UnixTimeStampToDateTime(Convert.ToDouble(ev["t"])).AddHours(3);
                        rezult.Add(rw);
                        var rw1 = rw.Clone();
                        rw1.TeamName = ev["c2"].ToString();

                        rezult.Add(rw1);
                    }
                }
            }

            return(rezult);
        }
        public List <SiteRow> ParseAnonsLive()
        {
            var       rezultList = new List <SiteRow>();
            WebClient wb         = new WebClient();

            wb.Encoding = Encoding.GetEncoding(1251);
            var response = wb.DownloadString($"{_url}/live.html");
            var parser   = new HtmlParser();

            IHtmlDocument document = parser.Parse(response);

            var table = document.GetElementById("sheduled");

            if (table == null)
            {
                throw new ArgumentException("Нет таблицы с прелайвом");
            }

            foreach (var key in table.Children[1].Children[0].Children)
            {
                if (key.ClassName.StartsWith("sport"))
                {
                    var sport = key.Children[0].TextContent;

                    foreach (var item in key.Children[1].Children)
                    {
                        if (string.IsNullOrWhiteSpace(item.Id))
                        {
                            continue;
                        }

                        var liga = item.PreviousSibling.TextContent;

                        foreach (var ev in item.Children)
                        {
                            var sr = new SiteRow();
                            sr.Sport  = sport;
                            sr.Groupe = liga;
                            sr.Site   = Shared.Enums.ParserType.PariMatch;

                            int day = Int32.Parse(ev.Attributes["data-date"].Value);
                            var dt  = DateTime.Now;
                            if (dt.Day > day)
                            {
                                dt = dt.AddMonths(1);
                            }

                            sr.TimeStart = DateTime.Parse(day + "/" + dt.Date.Month + "/" + dt.Date.Year + " " + ev.LastElementChild.Children[0].Children[0].TextContent).AddHours(1);


                            sr.Match = ev.LastElementChild.Children[0].Children[1].TextContent;

                            if (sr.Match.Contains("угловые") || sr.Match.Contains("карточки"))
                            {
                                continue;
                            }
                            var teams = sr.Match.Replace(" - ", "|").Split('|');
                            sr.TeamName = teams[0];
                            rezultList.Add(sr);

                            var sr1 = sr.Clone();
                            sr1.TeamName = teams[1];
                            rezultList.Add(sr1);
                        }
                    }
                }
            }

            return(rezultList);
        }
Ejemplo n.º 5
0
        private List <SiteRow> parsePage(string link)
        {
            var rezult = new List <SiteRow>();

            WebClient wb = new WebClient();

            wb.Encoding = Encoding.UTF8;
            var          respone = wb.DownloadString(link);
            HtmlDocument doc     = new HtmlDocument();

            doc.LoadHtml(respone);

            var name_node = doc.DocumentNode.SelectSingleNode("//a[@class=\"sport-category-label\"]");

            var blocks = doc.DocumentNode.SelectNodes("//div[@class=\"category-container\"]").ToList();

            foreach (var block in blocks)
            {
                string groupe = block.ChildNodes[1].ChildNodes[1].ChildNodes[1].ChildNodes[3].InnerText.Trim();

                var teams = block.ChildNodes[3].ChildNodes[3].ChildNodes[1].ChildNodes;

                foreach (var row in teams)
                {
                    if (row.Name == "tbody" && row.Attributes["data-event-treeid"] != null)
                    {
                        var     current = row.ChildNodes[1].ChildNodes[1].ChildNodes[1].ChildNodes;
                        SiteRow rw      = new SiteRow();
                        rw.Sport  = name_node.InnerText.Trim();
                        rw.Groupe = groupe;
                        rw.Site   = Shared.Enums.ParserType.Marafon;
                        var dt = current[1].ChildNodes[3].InnerText.Trim();
                        if (dt.Contains("ноя"))
                        {
                            dt = dt.Replace(" ноя", ".11.2016");
                        }
                        else if (dt.Contains("дек"))
                        {
                            dt = dt.Replace(" дек", ".12.2016");
                        }
                        else if (dt.Contains("янв"))
                        {
                            dt = dt.Replace(" янв ", ".01.");
                        }
                        else if (dt.Contains("фев"))
                        {
                            dt = dt.Replace(" фев ", ".01.");
                        }
                        else
                        {
                        }
                        rw.TimeStart = DateTime.Parse(dt);
                        rw.TeamName  = current[1].ChildNodes[1].ChildNodes[1].ChildNodes[3].InnerText.Trim();

                        rezult.Add(rw);

                        var rw1 = rw.Clone();
                        rw1.TeamName = current[3].ChildNodes[1].ChildNodes[1].ChildNodes[3].InnerText.Trim();
                        rezult.Add(rw1);
                    }
                }
            }

            return(rezult);
        }
Ejemplo n.º 6
0
        public List <SiteRow> ParseAnonsLive(DateTime date)
        {
            var rezult = new List <SiteRow>();

            WebClient wb = new WebClient();

            wb.Encoding = Encoding.UTF8;
            var uri      = $"{url}/su/live/announces?form_name=form&calendar=" + date.ToString("dd.MM.yyyy") + "&announce_sort=BY_TIME&sport_select=ALL&pageAction=default";
            var response = wb.DownloadString(uri);
            var json     = JArray.Parse(response);

            HtmlDocument doc = new HtmlDocument();

            if (json.First["content"] == null)
            {
                return(new List <SiteRow>());
            }
            doc.LoadHtml(json.First["content"].ToString());

            var nodes = doc.DocumentNode.SelectNodes("//tr[@class=\"announce\"]");

            foreach (var key in nodes)
            {
                var t = key.ChildNodes[1].ChildNodes[1].ChildNodes;

                var rw = new SiteRow();
                var dt = t[1].InnerText.Trim();
                if (dt.Contains("ноя"))
                {
                    dt = dt.Replace(" ноя", ".11.2017 ");
                }
                else if (dt.Contains("дек"))
                {
                    dt = dt.Replace(" дек", ".12.2017 ");
                }
                else if (dt.Contains("янв"))
                {
                    dt = dt.Replace(" янв ", ".01.2017 ");
                }
                else if (dt.Contains("фев"))
                {
                    dt = dt.Replace(" фев ", ".02.2017 ");
                }
                else if (dt.Contains("мар"))
                {
                    dt = dt.Replace(" мар ", ".03.2017 ");
                }
                else if (dt.Contains("апр"))
                {
                    dt = dt.Replace(" апр ", ".04.2017 ");
                }
                else if (dt.Contains("май"))
                {
                    dt = dt.Replace(" май ", ".05.2017 ");
                }
                else
                {
                }
                rw.TimeStart = DateTime.Parse(dt);

                rw.Site  = Shared.Enums.ParserType.Marafon;
                rw.Sport = t[3].InnerText.Split('.').First().Trim();
                var teams = t[3].ChildNodes[1].InnerText.Replace("&nbsp;", "").Replace(" - ", "|").Split('|');

                if (teams.Count() != 2)
                {
                    teams = t[3].ChildNodes[1].InnerText.Replace("&nbsp;", "").Replace(" @ ", "|").Split('|');
                }
                if (teams.Length != 2)
                {
                    continue;
                }

                rw.Groupe   = t[3].ChildNodes[0].InnerText.Replace(rw.Sport + ". ", "").Trim();
                rw.TeamName = teams[0];

                rw.Match = $"{rw.TeamName} - {teams[1]}";

                rezult.Add(rw);

                var rw1 = rw.Clone();
                rw1.TeamName = teams[1];
                rezult.Add(rw1);
            }


            return(rezult);
        }
        public List <SiteRow> ParseAnonsLive()
        {
            string adress = GetApiAdress();

            WebClient wb = new GZipWebClient();

            wb.Encoding = Encoding.UTF8;
            var respone = wb.DownloadString($"https:{adress}/line/currentLine/ru/");

            var json = JObject.Parse(respone);

            var rezult = new List <SiteRow>();
            var events = json["events"].Where(x => x["level"].ToString() == "1").ToList();

            foreach (var ev in events)
            {
                if (ev["state"]?["willBeLive"]?.ToString() == "True")
                {
                }
                else
                {
                    continue;
                }
                SiteRow rw = new SiteRow();
                rw.Site      = ParserType.Fonbet;
                rw.TeamName  = ev["team1"].ToString();
                rw.TimeStart = UnixTimeStampToDateTime(SetDouble(ev["startTime"].ToString())).AddHours(3);
                var sport = json["sports"].Where(x => x["id"].ToString() == ev["sportId"].ToString()).ToList().First();
                rw.Groupe = sport["name"].ToString();

                rw.Sport = rw.Groupe.Split('.').First().Trim();
                rw.Match = $"{rw.TeamName} - {ev["team2"]}";

                rezult.Add(rw);

                var rw2 = rw.Clone();
                rw2.TeamName = ev["team2"].ToString();


                rezult.Add(rw2);
            }

            wb      = new GZipWebClient();
            respone = wb.DownloadString($"https:{adress}/live/currentLine/ru/");
            json    = JObject.Parse(respone);
            events  = json["events"].Where(x => x["level"].ToString() == "1").ToList();
            foreach (JToken ev in events)
            {
                SiteRow rw = new SiteRow();
                rw.Site      = ParserType.Fonbet;
                rw.TeamName  = ev["team1"].ToString();
                rw.TimeStart = UnixTimeStampToDateTime(SetDouble(ev["startTime"].ToString())).AddHours(3);
                var sport = json["sports"].Where(x => x["id"].ToString() == ev["sportId"].ToString()).ToList().First();
                rw.Groupe = sport["name"].ToString();

                rw.Sport = rw.Groupe.Split('.').First().Trim();
                rw.Match = $"{rw.TeamName} - {ev["team2"]}";

                rezult.Add(rw);

                var rw2 = rw.Clone();
                rw2.TeamName = ev["team2"].ToString();


                rezult.Add(rw2);
            }


            rezult = rezult.OrderBy(x => x.TimeStart).ToList();
            return(rezult);
        }
        public List <SiteRow> ParseAnonsLive()
        {
            List <SiteRow> rezult = new List <SiteRow>();

            WebClient wb = new WebClient();

            wb.Encoding = Encoding.UTF8;
            var          response = wb.DownloadString(url + "/live");
            HtmlDocument doc      = new HtmlDocument();

            doc.LoadHtml(response);

            var table = doc.DocumentNode.SelectSingleNode("//table[@class=\"live-index-schedule-table\"]");

            if (table == null)
            {
                throw new ArgumentNullException($"{typeof(Zenit)}: Ошибка получения таблицы с Анонсом.");
            }

            var rows = table.FirstChild.ChildNodes.Where(x => x.Name == "tr").ToList();

            for (int i = 0; i < rows.Count; i++)
            {
                string ligaName  = rows[i].InnerText.Trim();
                string SportName = ligaName.Split('.').First();
                ligaName = ligaName.Replace(SportName + ".", "");
                while (true)
                {
                    if (i == rows.Count - 1)
                    {
                        break;
                    }
                    i++;
                    if (rows[i].Attributes["class"].Value == "live-index-schedule-row")
                    {
                        i--;
                        break; // вываливаемся из while
                    }

                    SiteRow sr = new SiteRow();
                    sr.Sport     = SportName;
                    sr.Groupe    = ligaName;
                    sr.Match     = rows[i].ChildNodes[3].InnerText;
                    sr.TimeStart = DateTime.Parse(rows[i].ChildNodes[1].InnerText.Replace(" ", "/2017 "));
                    sr.Site      = Shared.Enums.ParserType.Zenit;

                    string[] teams = sr.Match.Replace(" - ", "|").Split('|');
                    sr.TeamName = teams[0];
                    rezult.Add(sr);

                    var sr1 = sr.Clone();

                    sr1.TeamName = teams[1];
                    rezult.Add(sr1);
                }
            }

            var uri = new Uri(url).Host;

            response = wb.DownloadString($"https://m.{uri}/mbzenit/ajax/live/livedata?mob-all-live");
            var json = JObject.Parse(response);

            if (json["result"]?["games"] != null)
            {
                foreach (JToken jToken in json["result"]["games"])
                {
                    SiteRow sr   = new SiteRow();
                    var     liga =
                        json["result"]["league"].FirstOrDefault(
                            x => x.First["id"].ToString() == jToken.First["lid"].ToString());

                    var sport =
                        json["result"]["sport"].FirstOrDefault(
                            x => x.First["id"].ToString() == liga.First["sid"]?.ToString());

                    sr.Sport = sport.First["name"].ToString().Replace("Он-лайн. ", "");
                    if (string.IsNullOrWhiteSpace(sr.Sport))
                    {
                        sr.Sport = "Nan";
                    }
                    sr.Groupe    = liga.First["name"].ToString();
                    sr.Match     = $"{jToken.First["c1"]} - {jToken.First["c2"]}";
                    sr.TimeStart = UnixTimeStampToDateTime(Convert.ToDouble(jToken.First["time"])).AddHours(3);
                    sr.Site      = Shared.Enums.ParserType.Zenit;
                    sr.TeamName  = jToken.First["c1"].ToString();
                    rezult.Add(sr);

                    var sr1 = sr.Clone();
                    sr1.TeamName = jToken.First["c2"].ToString();
                    rezult.Add(sr1);
                }
            }

            return(rezult);
        }