public override bool Parse(string page, ref List <ParsedDataFromPage> PD)
        {
            var doc = new HtmlAgilityPack.HtmlDocument();

            doc.LoadHtml(page);


            if (doc.DocumentNode.SelectSingleNode("//div[@class='bets ml']") == null)
            {
                return(false);
            }

            foreach (var node in doc.DocumentNode.SelectNodes("//div[@class='bets ml']") ?? Enumerable.Empty <HtmlNode>())
            {
                var teams = node.SelectSingleNode(".//dt[@class='team_betting ']");
                if (teams == null)
                {
                    continue;
                }

                string Team1 = teams.SelectSingleNode(".//span[1]").InnerText;
                string Team2 = teams.SelectSingleNode(".//span[2]").InnerText;

                var odds = node.SelectSingleNode(".//dd");
                if (odds == null)
                {
                    continue;
                }

                string catchstr = odds.SelectSingleNode(".//ul/li[1]").InnerText;
                double x1       = 1;
                if (catchstr != null && TryToParse.ParseDouble(catchstr, out x1))
                {
                }

                catchstr = odds.SelectSingleNode(".//ul/li[2]").InnerText;
                double x0 = 1;
                if (catchstr != null && TryToParse.ParseDouble(catchstr, out x0))
                {
                }

                catchstr = odds.SelectSingleNode(".//ul/li[3]").InnerText;
                double x2 = 1;
                if (catchstr != null && TryToParse.ParseDouble(catchstr, out x2))
                {
                }


                ParsedDataFromPage nob = new ParsedDataFromPage();

                nob.Team1 = Team1;
                nob.Team2 = Team2;
                nob.X[0]  = x0;
                nob.X[1]  = x1;
                nob.X[2]  = x2;
                PD.Add(nob);
            }

            return(true);
        }
Esempio n. 2
0
        public override bool Parse(string page, ref List <ParsedDataFromPage> PD)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(page);

            if (doc.DocumentNode.SelectSingleNode(".//tbody[contains(@class,'evt')]") == null)
            {
                return(false);
            }



            foreach (var node in doc.DocumentNode.SelectNodes(".//tbody[contains(@class,'evt')]") ?? Enumerable.Empty <HtmlNode>())
            {
                var t1 = node.SelectSingleNode(".//tr[1]");
                var t2 = node.SelectSingleNode(".//tr[2]");
                if (t1 == null || t2 == null)
                {
                    continue;
                }

                string Team1 = t1.SelectSingleNode(".//span[contains(@class,'selection-txt')]").InnerText;
                string Team2 = t2.SelectSingleNode(".//span[contains(@class,'selection-txt')]").InnerText;

                string h1 = t1.SelectSingleNode(".//div[@class='hdp']").InnerText;
                string h2 = t2.SelectSingleNode(".//div[@class='hdp']").InnerText;
                double x1 = 0;
                if (h1 == "+0.5")
                {
                    string catchstr = t1.SelectSingleNode(".//td[@class='col-hdp-odds']/span").InnerText;
                    if (catchstr != null && TryToParse.ParseDouble(catchstr, out x1))
                    {
                    }
                }

                double x2 = 0;
                if (h2 == "+0.5")
                {
                    string catchstr = t2.SelectSingleNode(".//td[@class='col-hdp-odds']/span").InnerText;
                    if (catchstr != null && TryToParse.ParseDouble(catchstr, out x2))
                    {
                    }
                }
                if (x1 == 0 && x2 == 0)
                {
                    continue;
                }

                ParsedDataFromPage nob = new ParsedDataFromPage();

                nob.Team1 = Team1;
                nob.Team2 = Team2;
                nob.X[1]  = x1;
                nob.X[2]  = x2;
                PD.Add(nob);
            }
            return(true);
        }
Esempio n. 3
0
        private void MenuItem_Click_CalcFreeBet(object sender, RoutedEventArgs e)
        {
            if (LWHedge.Items.Count < 1)
            {
                return;
            }
            ListViewHedgeData lw    = (ListViewHedgeData)LWHedge.SelectedItems[0];
            double            koef1 = 2;
            double            koef2 = 2;

            TryToParse.ParseDouble(lw.Back, out koef1);
            TryToParse.ParseDouble(lw.Lay, out koef2);
            OpenWindow_FreeBet(true, koef1, koef2);
        }
        void tb_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox tb = (TextBox)e.Source;

            StackPanel sp = tb.Parent as StackPanel;

            CheckBox cb = sp.Children[0] as CheckBox;

            string str = tb.Text;

            double value;

            if (str != null && TryToParse.ParseDouble(str, out value))
            {
                int index = MainF.Bookmakers.FindIndex(item => item.Name == cb.Content.ToString());
                if (index != -1)
                {
                    MainF.Bookmakers[index].Limit = value;
                }
            }
        }
Esempio n. 5
0
        public override bool Parse(string page, ref List <ParsedDataFromPage> PD)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(page);
            if (doc.DocumentNode.SelectSingleNode("//tr[@class='rowOdd']") == null)
            {
                return(false);
            }

            foreach (var node in doc.DocumentNode.SelectNodes("//tr[@class='rowOdd']") ?? Enumerable.Empty <HtmlNode>())
            {
                var teams = node.SelectSingleNode(".//span[contains(@id,'mkt_namespace')]");
                if (teams == null)
                {
                    continue;
                }



                string[] buf = teams.InnerText.Replace("&nbsp;", "").Replace(" v ", "-").Split('-');



                var v1 = node.SelectSingleNode(".//td[5]");
                var v0 = node.SelectSingleNode(".//td[6]");
                var v2 = node.SelectSingleNode(".//td[7]");

                if (v1 == null || v0 == null || v2 == null)
                {
                    continue;
                }

                string catchstr = v1.InnerText.Trim();
                double x1       = 1;
                if (catchstr.Contains('/'))
                {
                    List <double> d = new List <double>(Array.ConvertAll(catchstr.Split('/'), double.Parse));
                    x1 = Math.Round(d[0] / d[1] + 1, 2);
                }
                else
                {
                    if (catchstr != null && TryToParse.ParseDouble(catchstr, out x1))
                    {
                    }
                }

                catchstr = v0.InnerText.Trim();
                double x0 = 1;
                if (catchstr.Contains('/'))
                {
                    List <double> d = new List <double>(Array.ConvertAll(catchstr.Split('/'), double.Parse));
                    x0 = Math.Round(d[0] / d[1] + 1, 2);
                }
                else
                {
                    if (catchstr != null && TryToParse.ParseDouble(catchstr, out x0))
                    {
                    }
                }

                catchstr = v2.InnerText.Trim();
                double x2 = 1;
                if (catchstr.Contains('/'))
                {
                    List <double> d = new List <double>(Array.ConvertAll(catchstr.Split('/'), double.Parse));
                    x2 = Math.Round(d[0] / d[1] + 1, 2);
                }
                else
                {
                    if (catchstr != null && TryToParse.ParseDouble(catchstr, out x2))
                    {
                    }
                }


                //string Team1 = buf[0].Trim();
                //string Team2 = buf[1].Trim();

                string Team1 = Regex.Replace(buf[0], RepPatter, "").ToUpper().Trim();
                string Team2 = Regex.Replace(buf[1], RepPatter, "").ToUpper().Trim();

                ParsedDataFromPage nob = new ParsedDataFromPage();
                nob.Team1 = Team1;
                nob.Team2 = Team2;
                nob.X[0]  = x0;
                nob.X[1]  = x1;
                nob.X[2]  = x2;

                PD.Add(nob);
            }


            return(true);
        }
        public override bool Parse(string page, ref List <ParsedDataFromPage> PD)
        {
            if (page.Contains("\"offset\""))
            {
                int poz = page.IndexOf("]},{");
                if (poz == -1)
                {
                    return(false);
                }
                poz = 0;
                while (poz != -1)
                {
                    int poznext = page.IndexOf("]},{", poz + 1);
                    if (poznext == -1)
                    {
                        poznext = page.Length - 1;
                    }

                    int aa = page.IndexOf("\"Match Odds\"", poz);
                    if (aa > poznext || aa == -1)
                    {
                        poz = page.IndexOf("]},{", poz + 1); continue;
                    }

                    StringBuilder country = new StringBuilder();

                    int p1 = poz;
                    while (true)
                    {
                        var q1 = page.IndexOf("\"COUNTRY\"", p1, poznext - p1 - 2);
                        if (q1 == -1)
                        {
                            break;
                        }
                        else
                        {
                            country.Append(page.Substring(q1 + 22, page.IndexOf("\"", q1 + 23) - q1 - 22)).Append(" ");
                        }
                        p1 = q1 + 1;
                    }

                    p1 = poz;
                    StringBuilder competition = new StringBuilder();
                    while (true)
                    {
                        var q1 = page.IndexOf("\"COMPETITION\"", p1, poznext - p1 - 2);
                        if (q1 == -1)
                        {
                            break;
                        }
                        else
                        {
                            string buf = page.Substring(q1 + 26, page.IndexOf("\"", q1 + 27) - q1 - 26).Trim();
                            if (!buf.Contains("live-betting"))
                            {
                                competition.Append(buf + " ");
                            }
                        }
                        p1 = q1 + 1;
                    }
                    if (competition.Length == 0)
                    {
                        poz = page.IndexOf("]},{", poz + 1); continue;
                    }
                    string league = (country.ToString() + competition.ToString().Trim()).Replace("-", " ").ToUpper();



                    int index = MainF.Leagues.FindIndex(i => i.Name == league);
                    if (index != -1)
                    {
                        if (!MainF.Leagues[index].State)
                        {
                            poz = page.IndexOf("]},{", poz + 1); continue;
                        }
                    }
                    else
                    {
                        MainF.Leagues.Add(new LeagueState()
                        {
                            Name = league, State = true
                        });
                    }

                    var n1 = page.IndexOf("\"name\"", aa);
                    var n2 = page.IndexOf("\"name\"", n1 + 1);
                    var n0 = page.IndexOf("\"name\"", n2 + 1);



                    if (n1 == -1 || n2 == -1 || n0 == -1)
                    {
                        poz = page.IndexOf("]},{", poz + 1); continue;
                    }
                    //-----------------------------------------------------------------
                    var    b1        = page.IndexOf("\"back\"", n1, n2 - n1);
                    double backodds1 = 0;
                    if (b1 != -1)
                    {
                        var    d1   = page.IndexOf("\"decimal-odds\"", b1);
                        string back = page.Substring(d1 + 15, page.IndexOf(",", d1) - d1 - 15);
                        if (back != null && TryToParse.ParseDouble(back, out backodds1))
                        {
                        }
                    }

                    var l1 = page.IndexOf("\"lay\"", n1, n2 - n1);

                    double layodds1   = 0;
                    double available1 = 0;
                    if (l1 != -1)
                    {
                        var    d1      = page.IndexOf("\"decimal-odds\"", l1);
                        string laysize = page.Substring(l1 + 25, page.IndexOf(",", l1 + 10) - l1 - 25);
                        if (laysize != null && TryToParse.ParseDouble(laysize, out available1))
                        {
                        }
                        string lay1 = page.Substring(d1 + 15, page.IndexOf(",", d1) - d1 - 15);
                        if (lay1 != null && TryToParse.ParseDouble(lay1, out layodds1))
                        {
                        }
                    }
                    //-----------------------------------------------------------------
                    var    b2        = page.IndexOf("\"back\"", n2, n0 - n2);
                    double backodds2 = 0;
                    if (b2 != -1)
                    {
                        var    d2   = page.IndexOf("\"decimal-odds\"", b2);
                        string back = page.Substring(d2 + 15, page.IndexOf(",", d2) - d2 - 15);
                        if (back != null && TryToParse.ParseDouble(back, out backodds2))
                        {
                        }
                    }

                    var l2 = page.IndexOf("\"lay\"", n2, n0 - n2);

                    double layodds2   = 0;
                    double available2 = 0;
                    if (l2 != -1)
                    {
                        var    d2      = page.IndexOf("\"decimal-odds\"", l2);
                        string laysize = page.Substring(l2 + 25, page.IndexOf(",", l2 + 10) - l2 - 25);
                        if (laysize != null && TryToParse.ParseDouble(laysize, out available2))
                        {
                        }
                        string lay2 = page.Substring(d2 + 15, page.IndexOf(",", d2) - d2 - 15);
                        if (lay2 != null && TryToParse.ParseDouble(lay2, out layodds2))
                        {
                        }
                    }
                    //-----------------------------------------------------------------
                    var    b0        = page.IndexOf("\"back\"", n0, poznext - n0 - 1);
                    double backodds0 = 0;
                    if (b0 != -1)
                    {
                        var    d0   = page.IndexOf("\"decimal-odds\"", b0);
                        string back = page.Substring(d0 + 15, page.IndexOf(",", d0) - d0 - 15);
                        if (back != null && TryToParse.ParseDouble(back, out backodds0))
                        {
                        }
                    }

                    var l0 = page.IndexOf("\"lay\"", n0, poznext - n0 - 1);

                    double layodds0   = 0;
                    double available0 = 0;

                    if (l0 != -1)
                    {
                        var    d0      = page.IndexOf("\"decimal-odds\"", l0);
                        string laysize = page.Substring(l0 + 25, page.IndexOf(",", l0 + 10) - l0 - 25);
                        if (laysize != null && TryToParse.ParseDouble(laysize, out available0))
                        {
                        }
                        string lay0 = page.Substring(d0 + 15, page.IndexOf(",", d0) - d0 - 15);
                        if (lay0 != null && TryToParse.ParseDouble(lay0, out layodds0))
                        {
                        }
                    }
                    //-----------------------------------------------------------------


                    var s = page.IndexOf("\"start\"", poz, poznext - poz - 1);
                    var f = page.IndexOf("\"in-running-flag\"", poz, poznext - poz - 2);

                    string starttime = "";
                    if (s != -1)
                    {
                        starttime = page.Substring(s + 9, page.IndexOf(",", s + 10) - s - 10);
                    }

                    string flag = "false";
                    if (f != -1)
                    {
                        flag = page.Substring(f + 18, page.IndexOf(",", f + 10) - f - 18);
                    }

                    poz = poznext;

                    ParsedDataFromPage nob = new ParsedDataFromPage();

                    nob.time   = starttime;
                    nob.League = league.ToUpper().Trim();
                    nob.Team1  = page.Substring(n1 + 8, page.IndexOf(",", n1) - n1 - 9);
                    nob.Team2  = page.Substring(n2 + 8, page.IndexOf(",", n2) - n2 - 9);



                    nob.Lay[0] = Math.Round(layodds0, 2);
                    nob.Lay[1] = Math.Round(layodds1, 2);
                    nob.Lay[2] = Math.Round(layodds2, 2);


                    nob.X[0] = Math.Round(backodds0, 2);
                    nob.X[1] = Math.Round(backodds1, 2);
                    nob.X[2] = Math.Round(backodds2, 2);

                    nob.Size[0] = Math.Round(available0, 0);
                    nob.Size[1] = Math.Round(available1, 0);
                    nob.Size[2] = Math.Round(available2, 0);
                    nob.delete  = Convert.ToBoolean(flag);
                    PD.Add(nob);


                    //    System.Windows.Forms.MessageBox.Show(nob.Team1 + "  " + nob.Team2 + "  " + available0 + "  " + available1 + "  " + available2);
                }
            }

            else
            {
                var doc = new HtmlDocument();
                doc.LoadHtml(page);

                if (doc.DocumentNode.SelectSingleNode("//li[contains(@class,'event')]") == null)
                {
                    return(false);
                }

                var    check  = doc.DocumentNode.SelectSingleNode("//a[@class='breadcrumb ']/span");
                string league = "Unknown";
                if (check != null)
                {
                    league = check.InnerText.Trim();
                }

                string catchstr;
                foreach (var node in doc.DocumentNode.SelectNodes("//li[contains(@class,'event')]") ?? Enumerable.Empty <HtmlNode>())
                {
                    var checkevent = node.SelectSingleNode(".//a[contains(@class,'details')]");
                    if (checkevent != null)
                    {
                        if (!checkevent.InnerText.ToUpper().Contains(" VS "))
                        {
                            continue;
                        }
                        if (checkevent.Attributes["class"].Value.Contains("in_play"))
                        {
                            string[] d = checkevent.SelectSingleNode(".//h2").InnerText.Replace(" vs ", "-").Split('-');

                            ParsedDataFromPage nobdel = new ParsedDataFromPage();

                            nobdel.Team1  = d[0].Trim();
                            nobdel.Team2  = d[1].Trim();
                            nobdel.delete = true;
                            PD.Add(nobdel);
                            continue;
                        }
                    }

                    var a = node.SelectSingleNode(".//div[@class='runners']/ul/li[2]");
                    if (a == null)
                    {
                        continue;
                    }
                    var a1 = a.SelectSingleNode(".//h4");
                    if (a1 == null)
                    {
                        continue;
                    }

                    string Team1 = a1.InnerText.Trim();

                    var a2 = a.SelectSingleNode(".//ol[@class='lay']").SelectSingleNode(".//span[@class='odds']");
                    if (a2 == null)
                    {
                        continue;
                    }
                    catchstr = a2.InnerText.Trim();
                    double layodds1 = 1;
                    if (catchstr != null && TryToParse.ParseDouble(catchstr, out layodds1))
                    {
                    }

                    a2 = a.SelectSingleNode(".//ol[@class='lay']").SelectSingleNode(".//span[@class='amount']");
                    if (a2 == null)
                    {
                        continue;
                    }
                    string laysize1 = a2.InnerText.Trim();


                    var b = node.SelectSingleNode(".//div[@class='runners']/ul/li[3]");

                    if (b == null)
                    {
                        continue;
                    }
                    a1 = b.SelectSingleNode(".//h4");
                    if (a1 == null)
                    {
                        continue;
                    }

                    string Team2 = a1.InnerText.Trim();


                    a2 = b.SelectSingleNode(".//ol[@class='lay']").SelectSingleNode(".//span[@class='odds']");
                    if (a2 == null)
                    {
                        continue;
                    }
                    catchstr = a2.InnerText.Trim();
                    double layodds2 = 1;
                    if (catchstr != null && TryToParse.ParseDouble(catchstr, out layodds2))
                    {
                    }

                    a2 = b.SelectSingleNode(".//ol[@class='lay']").SelectSingleNode(".//span[@class='amount']");
                    if (a2 == null)
                    {
                        continue;
                    }
                    string laysize2 = a2.InnerText.Trim();


                    var c = node.SelectSingleNode(".//div[@class='runners']/ul/li[4]");

                    if (c == null)
                    {
                        continue;
                    }
                    a1 = c.SelectSingleNode(".//h4");
                    if (a1 == null)
                    {
                        continue;
                    }

                    string t3 = a1.InnerText.Trim();

                    a2 = c.SelectSingleNode(".//ol[@class='lay']").SelectSingleNode(".//span[@class='odds']");
                    if (a2 == null)
                    {
                        continue;
                    }
                    double layodds0 = 1;
                    catchstr = a2.InnerText.Trim();
                    if (catchstr != null && TryToParse.ParseDouble(catchstr, out layodds0))
                    {
                    }

                    a2 = c.SelectSingleNode(".//ol[@class='lay']").SelectSingleNode(".//span[@class='amount']");
                    if (a2 == null)
                    {
                        continue;
                    }
                    string laysize0 = a2.InnerText.Trim();

                    var time = node.SelectSingleNode(".//div[@class='time']");

                    string t    = "";
                    var    hour = time.SelectSingleNode(".//span[@class='hour']");
                    if (hour.InnerText != "")
                    {
                        var min = time.SelectSingleNode(".//span[@class='minute']");
                        t = hour.InnerText.Trim() + ":" + min.InnerText.Trim() + " Today";
                    }
                    else
                    {
                        t = time.SelectSingleNode(".//div[@class='date']").InnerText.Trim();
                    }



                    ParsedDataFromPage nob = new ParsedDataFromPage();
                    if (league.Length < 1)
                    {
                        league = "Empty";
                    }
                    nob.time   = t;
                    nob.League = league;
                    nob.Team1  = Team1;
                    nob.Team2  = Team2;
                    nob.X[0]   = layodds0;
                    nob.X[1]   = layodds1;
                    nob.X[2]   = layodds2;

                    PD.Add(nob);
                }
            }
            return(true);
        }
Esempio n. 7
0
        public override bool Parse(string page, ref List <ParsedDataFromPage> PD)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(page);

            if (doc.DocumentNode.SelectSingleNode("//tbody[contains(@ng-repeat,'event in events')]") == null)
            {
                return(false);
            }

            foreach (var node in doc.DocumentNode.SelectNodes("//tbody[contains(@ng-repeat,'event in events')]") ?? Enumerable.Empty <HtmlNode>())
            {
                var l1 = node.SelectSingleNode(".//tr[1]");
                var l2 = node.SelectSingleNode(".//tr[2]");
                var l0 = node.SelectSingleNode(".//tr[3]");
                if (l1 == null || l2 == null)
                {
                    continue;
                }

                var v1 = l1.SelectSingleNode(".//span[contains(@ng-if,'participant.MoneyLine')]");
                if (v1 == null)
                {
                    continue;
                }

                var v2 = l2.SelectSingleNode(".//span[contains(@ng-if,'participant.MoneyLine')]");
                if (v2 == null)
                {
                    continue;
                }

                var v0 = l0.SelectSingleNode(".//span[contains(@ng-if,'participant.MoneyLine')]");
                if (v0 == null)
                {
                    continue;
                }

                string catchstr = v1.InnerText;
                double x1       = 1;
                if (catchstr != null && TryToParse.ParseDouble(catchstr, out x1))
                {
                }

                catchstr = v2.InnerText;
                double x2 = 1;
                if (catchstr != null && TryToParse.ParseDouble(catchstr, out x2))
                {
                }

                catchstr = v0.InnerText;
                double x0 = 1;
                if (catchstr != null && TryToParse.ParseDouble(catchstr, out x0))
                {
                }

                var t1 = l1.SelectSingleNode(".//span[contains(@ng-if,'participant.Name')]");
                var t2 = l2.SelectSingleNode(".//span[contains(@ng-if,'participant.Name')]");

                if (t1 == null || t2 == null)
                {
                    continue;
                }



                //var h1 = l1.SelectSingleNode(".//span[@class='spread ng-binding']");
                //var h2 = l2.SelectSingleNode(".//span[@class='spread ng-binding']");

                //if (h1 == null || h2 == null) continue;
                //if (h1.InnerText != "+0.5" && h2.InnerText != "+0.5") continue;

                //double x1 = 0;
                //if (h1.InnerText == "+0.5")
                //{
                //    string catchstr = l1.SelectSingleNode(".//span[@class='price ng-binding']").InnerText;
                //    if (catchstr != null && TryToParse.ParseDouble(catchstr, out x1)) { }
                //}
                //double x2 = 0;
                //if (h2.InnerText == "+0.5")
                //{
                //    string catchstr = l2.SelectSingleNode(".//span[@class='price ng-binding']").InnerText;
                //    if (catchstr != null && TryToParse.ParseDouble(catchstr, out x2)) { }
                //}

                ParsedDataFromPage nob = new ParsedDataFromPage();

                nob.Team1 = Regex.Replace(t1.InnerText, RepPatter, "").ToUpper().Trim();
                nob.Team2 = Regex.Replace(t2.InnerText, RepPatter, "").ToUpper().Trim();
                nob.X[0]  = x0;
                nob.X[1]  = x1;
                nob.X[2]  = x2;
                PD.Add(nob);
            }


            return(true);
        }
        public override bool Parse(string page, ref List <ParsedDataFromPage> PD)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(page);
            if (doc.DocumentNode.SelectSingleNode("//tr[@class='event-header']") == null)
            {
                return(false);
            }

            foreach (var node in doc.DocumentNode.SelectNodes("//tr[@class='event-header']") ?? Enumerable.Empty <HtmlNode>())
            {
                try
                {
                    var teams = node.SelectSingleNode(".//span[@class='command text-underline']");
                    if (teams == null)
                    {
                        continue;
                    }

                    string Team1 = teams.SelectSingleNode(".//div[1]").InnerText;
                    string Team2 = teams.SelectSingleNode(".//div[2]").InnerText;


                    //string Team1 = Regex.Replace(teams.SelectSingleNode(".//div[1]").InnerText, BasicProperties.RepPatter, "").ToUpper().Trim();
                    //string Team2 = Regex.Replace(teams.SelectSingleNode(".//div[2]").InnerText, BasicProperties.RepPatter, "").ToUpper().Trim();


                    var v1 = node.SelectSingleNode(".//td[contains(@data-sel,'" + Team1 + "')]");
                    var v0 = node.SelectSingleNode(".//td[contains(@data-sel,'Draw')]");
                    var v2 = node.SelectSingleNode(".//td[contains(@data-sel,'" + Team2 + "')]");

                    if (v1 == null || v2 == null || v0 == null)
                    {
                        continue;
                    }

                    string catchstr = v1.InnerText.Trim();
                    double x1       = 1;
                    if (catchstr.Contains('/'))
                    {
                        List <double> d = new List <double>(Array.ConvertAll(catchstr.Split('/'), double.Parse));
                        x1 = Math.Round(d[0] / d[1] + 1, 2);
                    }
                    else
                    {
                        if (catchstr != null && TryToParse.ParseDouble(catchstr, out x1))
                        {
                        }
                    }


                    catchstr = v0.InnerText.Trim();
                    double x0 = 1;
                    if (catchstr.Contains('/'))
                    {
                        List <double> d = new List <double>(Array.ConvertAll(catchstr.Split('/'), double.Parse));
                        x0 = Math.Round(d[0] / d[1] + 1, 2);
                    }
                    else
                    {
                        if (catchstr != null && TryToParse.ParseDouble(catchstr, out x0))
                        {
                        }
                    }

                    catchstr = v2.InnerText.Trim();
                    double x2 = 1;
                    if (catchstr.Contains('/'))
                    {
                        List <double> d = new List <double>(Array.ConvertAll(catchstr.Split('/'), double.Parse));
                        x2 = Math.Round(d[0] / d[1] + 1, 2);
                    }
                    else
                    {
                        if (catchstr != null && TryToParse.ParseDouble(catchstr, out x2))
                        {
                        }
                    }



                    Team1 = Regex.Replace(teams.SelectSingleNode(".//div[1]").InnerText, RepPatter, "").ToUpper().Trim();
                    Team2 = Regex.Replace(teams.SelectSingleNode(".//div[2]").InnerText, RepPatter, "").ToUpper().Trim();

                    ParsedDataFromPage nob = new ParsedDataFromPage();

                    nob.Team1 = Team1;
                    nob.Team2 = Team2;
                    nob.X[0]  = x0;
                    nob.X[1]  = x1;
                    nob.X[2]  = x2;
                    PD.Add(nob);
                }
                catch (Exception)
                {
                    continue;
                }
            }
            return(true);
        }
        public static void LoadSettings(MainWindow MainF)
        {
            MainF.DefaultSettings();
            if (File.Exists(pathSettings))
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(pathSettings);

                foreach (XmlNode item in xd.SelectNodes("Settings/Bookmakers/BookMaker"))
                {
                    var c = item.SelectSingleNode(".//Name");
                    if (c == null)
                    {
                        continue;
                    }

                    string name  = c.InnerText;
                    int    index = MainF.Bookmakers.FindIndex(it => it.Name == name);

                    if (index < 0)
                    {
                        continue;
                    }

                    c = item.SelectSingleNode(".//Limit");
                    string strbuf = "1";
                    if (c != null)
                    {
                        strbuf = c.InnerText;
                    }
                    double limit = 1;
                    if (strbuf != null && TryToParse.ParseDouble(strbuf, out limit))
                    {
                    }


                    MainF.Bookmakers[index].Limit = limit;

                    c = item.SelectSingleNode(".//InUse");
                    if (c != null)
                    {
                        MainF.Bookmakers[index].InUse = Convert.ToBoolean(c.InnerText);
                    }

                    c = item.SelectSingleNode(".//Email");
                    if (c != null)
                    {
                        MainF.Bookmakers[index].EMailing = Convert.ToBoolean(c.InnerText);
                    }

                    c = item.SelectSingleNode(".//Dutch3Way");
                    if (c != null)
                    {
                        MainF.Bookmakers[index].Dutch3Way = Convert.ToBoolean(c.InnerText);
                    }

                    c = item.SelectSingleNode(".//EmailPLlimit");
                    if (c != null)
                    {
                        strbuf = c.InnerText;
                        if (strbuf != null && TryToParse.ParseDouble(strbuf, out limit) && limit > FootballHedge.Properties.Settings.Default.MailplLimit)
                        {
                            MainF.Bookmakers[index].PLlimit = limit;
                        }
                    }
                }
                foreach (XmlNode item in xd.SelectNodes("Settings/Leagues/League"))
                {
                    string league = item.SelectSingleNode(".//LeagueName").InnerText;
                    bool   value  = Convert.ToBoolean(item.SelectSingleNode(".//Value").InnerText);
                    int    index  = MainF.Leagues.FindIndex(i => i.Name == league);
                    if (index != -1)
                    {
                        MainF.Leagues[index].State = value;
                    }
                    else
                    {
                        MainF.Leagues.Add(new LeagueState()
                        {
                            Name = league, State = value
                        });
                    }
                }
                foreach (XmlNode item in xd.SelectNodes("Settings/SuspendedMatches/Match"))
                {
                    MainF.SuspendedMatches.Add(item.InnerText);
                }
            }
        }
        public void Load(List <FData> FootData, List <BasicBrokerData> Bookmakers)
        {
            if (File.Exists(pathAllMatches))
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(pathAllMatches);
                FootData.Clear();
                foreach (XmlNode item in xd.SelectNodes("Data/Match"))
                {
                    FData f = new FData();



                    if (item.SelectSingleNode(".//Team1") == null)
                    {
                        continue;
                    }
                    f.Team1 = item.SelectSingleNode(".//Team1").InnerText;

                    if (item.SelectSingleNode(".//Team2") == null)
                    {
                        continue;
                    }
                    f.Team2 = item.SelectSingleNode(".//Team2").InnerText;


                    if (item.SelectSingleNode(".//Match") == null)
                    {
                        continue;
                    }
                    f.Match = item.SelectSingleNode(".//Match").InnerText;

                    if (item.SelectSingleNode(".//League") == null)
                    {
                        continue;
                    }
                    f.League = item.SelectSingleNode(".//League").InnerText;


                    if (item.SelectSingleNode(".//Time") != null)
                    {
                        string time = time = item.SelectSingleNode(".//Time").InnerText;
                        try
                        {
                            DateTime buftime;
                            if (TryToParse.ParseDateTime(time, out buftime))
                            {
                                f.time = buftime;
                            }
                        }
                        catch (FormatException)
                        {
                            f.time = DateTime.Today;
                        }
                    }

                    for (int i = 0; i < Bookmakers.Count; i++)
                    {
                        BasicBrokerData data = Bookmakers[i];
                        if (item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/X0") == null)
                        {
                            continue;
                        }
                        f.AddNewItenToDictionary(i);
                        if (item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/LastUpdate") != null)
                        {
                            f.XKoef[i].LastUpdate = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/LastUpdate").InnerText;
                        }

                        double value = 1;
                        var    x     = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/X0");

                        if (x != null && TryToParse.ParseDouble(x.InnerText, out value))
                        {
                        }
                        f.XKoef[i].Koef[0] = value;

                        value = 1;
                        x     = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/X1");
                        if (x != null && TryToParse.ParseDouble(x.InnerText, out value))
                        {
                        }
                        f.XKoef[i].Koef[1] = value;

                        value = 1;
                        x     = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/X2");
                        if (x != null && TryToParse.ParseDouble(x.InnerText, out value))
                        {
                        }
                        f.XKoef[i].Koef[2] = value;

                        if (Bookmakers[i].Type == BrokerType.LAY)
                        {
                            value = 1;
                            x     = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/LX0");

                            if (x != null && TryToParse.ParseDouble(x.InnerText, out value))
                            {
                            }
                            f.Lay[0] = value;

                            value = 1;
                            x     = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/LX1");
                            if (x != null && TryToParse.ParseDouble(x.InnerText, out value))
                            {
                            }
                            f.Lay[1] = value;

                            value = 1;
                            x     = item.SelectSingleNode(".//BookieOdds/B_" + data.Name + "/LX2");
                            if (x != null && TryToParse.ParseDouble(x.InnerText, out value))
                            {
                            }
                            f.Lay[2] = value;
                        }
                    }

                    FootData.Add(f);
                }
            }
        }
        public override bool Parse(string page, ref List <ParsedDataFromPage> PD)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(page);

            if (doc.DocumentNode.SelectSingleNode(".//tr[contains(@id,'bu:od:or')]") == null)
            {
                return(false);
            }
            foreach (var node in doc.DocumentNode.SelectNodes(".//tr[contains(@id,'bu:od:or')]") ?? Enumerable.Empty <HtmlNode>())
            {
                var t1 = node.SelectSingleNode(".//td[3]");
                var t0 = node.SelectSingleNode(".//td[4]");
                var t2 = node.SelectSingleNode(".//td[5]");

                if (t1 == null || t0 == null || t2 == null)
                {
                    continue;
                }

                var te1 = t1.SelectSingleNode(".//span[@class='OddsL']");
                var te2 = t2.SelectSingleNode(".//span[@class='OddsL']");

                if (te1 == null || te2 == null)
                {
                    continue;
                }

                double x1 = 1;
                double x0 = 1;
                double x2 = 1;

                var v1 = t1.SelectSingleNode(".//span[@class='OddsR']");

                if (v1 != null)
                {
                    string catchstr = v1.InnerText;
                    if (catchstr != null && TryToParse.ParseDouble(catchstr, out x1))
                    {
                    }
                }

                var v0 = t0.SelectSingleNode(".//span[@class='OddsR']");
                if (v0 != null)
                {
                    string catchstr = v0.InnerText;
                    if (catchstr != null && TryToParse.ParseDouble(catchstr, out x0))
                    {
                    }
                }
                var v2 = t2.SelectSingleNode(".//span[@class='OddsR']");
                if (v2 != null)
                {
                    string catchstr = v2.InnerText;
                    if (catchstr != null && TryToParse.ParseDouble(catchstr, out x2))
                    {
                    }
                }



                ParsedDataFromPage nob = new ParsedDataFromPage();

                nob.Team1 = Regex.Replace(te1.InnerText.Replace("-", " "), RepPatter, "").ToUpper().Trim();
                nob.Team2 = Regex.Replace(te2.InnerText.Replace("-", " "), RepPatter, "").ToUpper().Trim();
                nob.X[0]  = Math.Round(x0, 2);
                nob.X[1]  = Math.Round(x1, 2);
                nob.X[2]  = Math.Round(x2, 2);
                PD.Add(nob);

                //System.Windows.Forms.MessageBox.Show(nob.Team1+"  "+nob.Team2);
            }



            return(true);
        }
Esempio n. 12
0
        public override bool Parse(string page, ref List <ParsedDataFromPage> PD)
        {
            var doc = new HtmlAgilityPack.HtmlDocument();

            doc.LoadHtml(page);

            if (doc.DocumentNode.SelectSingleNode("//tr[@class='col3 three-way']") == null)
            {
                return(false);
            }

            foreach (var node in doc.DocumentNode.SelectNodes("//tr[@class='col3 three-way']") ?? Enumerable.Empty <HtmlNode>())
            {
                var a1 = node.SelectSingleNode(".//td[1]");
                var a0 = node.SelectSingleNode(".//td[2]");
                var a2 = node.SelectSingleNode(".//td[3]");

                if (a1 == null || a0 == null || a2 == null || a1.SelectSingleNode(".//span[@class='option-name']") == null || a2.SelectSingleNode(".//span[@class='option-name']") == null)
                {
                    continue;
                }

                var    t1 = a1.SelectSingleNode(".//span[@class='odds']");
                double x1 = 1;
                if (t1 != null)
                {
                    string catchstr = t1.InnerText;
                    if (catchstr.Contains('/'))
                    {
                        List <double> d = new List <double>(Array.ConvertAll(catchstr.Split('/'), double.Parse));
                        x1 = Math.Round(d[0] / d[1] + 1, 2);
                    }
                    else
                    {
                        if (catchstr != null && TryToParse.ParseDouble(catchstr, out x1))
                        {
                        }
                    }
                }

                var    t0 = a0.SelectSingleNode(".//span[@class='odds']");
                double x0 = 1;
                if (t0 != null)
                {
                    string catchstr = t0.InnerText;
                    if (catchstr.Contains('/'))
                    {
                        List <double> d = new List <double>(Array.ConvertAll(catchstr.Split('/'), double.Parse));
                        x0 = Math.Round(d[0] / d[1] + 1, 2);
                    }
                    else
                    {
                        if (catchstr != null && TryToParse.ParseDouble(catchstr, out x0))
                        {
                        }
                    }
                }

                var    t2 = a2.SelectSingleNode(".//span[@class='odds']");
                double x2 = 1;
                if (t2 != null)
                {
                    string catchstr = t2.InnerText;
                    if (catchstr.Contains('/'))
                    {
                        List <double> d = new List <double>(Array.ConvertAll(catchstr.Split('/'), double.Parse));
                        x2 = Math.Round(d[0] / d[1] + 1, 2);
                    }
                    else
                    {
                        if (catchstr != null && TryToParse.ParseDouble(catchstr, out x2))
                        {
                        }
                    }
                }



                //string Team1 = a1.SelectSingleNode(".//span[@class='option-name']").InnerText;
                //string Team2 = a2.SelectSingleNode(".//span[@class='option-name']").InnerText;

                string Team1 = Regex.Replace(a1.SelectSingleNode(".//span[@class='option-name']").InnerText, RepPatter, "").ToUpper().Trim();
                string Team2 = Regex.Replace(a2.SelectSingleNode(".//span[@class='option-name']").InnerText, RepPatter, "").ToUpper().Trim();

                ParsedDataFromPage nob = new ParsedDataFromPage();
                nob.Team1 = Team1;
                nob.Team2 = Team2;
                nob.X[0]  = x0;
                nob.X[1]  = x1;
                nob.X[2]  = x2;
                PD.Add(nob);
                //   System.Windows.Forms.MessageBox.Show(nob.Team1 + "  " + nob.Team2 + "  " + nob.X[1].ToString() + "  " + nob.X[0].ToString() + "  " + nob.X[2].ToString());
            }

            return(true);
        }