예제 #1
0
        public float GetOddForMatch(string matchName)
        {
            float  matchOdd       = -1;
            string oddUrlForMatch = GetLinkForMatch(matchName);

            if (oddUrlForMatch != null)
            {
                string      matchUrlForOdds = "http://www.flashscore.com/match/" + oddUrlForMatch + "/#odds-comparison;over-under;full-time";
                IWebElement currentOddCell;
                string      currentOddCellString = null;
                JSDriver.Url = matchUrlForOdds;
                JSDriver.Navigate();

                string content = JSDriver.PageSource;
                ReadOnlyCollection <IWebElement> matchOdds = JSDriver.FindElementsById("odds_ou_1.5");
                if (matchOdds.Count > 0)
                {
                    currentOddCell       = matchOdds[0];
                    currentOddCellString = currentOddCell.Text;
                    Regex regex       = new Regex(@"([0-9]{1}).([0-9]{2})(\r)");
                    Match regex_match = regex.Match(currentOddCellString);
                    if (regex_match.Success)
                    {
                        matchOdd = float.Parse(regex_match.Value);
                    }
                }
                else
                {
                    matchOdd = NO_ODD_ON_FLASHSCORE;
                }
            }
            else if (oddUrlForMatch == "statelException")
            {
                return(-3);
            }
            return(matchOdd);
        }