Exemplo n.º 1
0
        private void LoadInOdds(HtmlDocument doc)
        {
            List <string> bookieCodesList = new List <string>();

            HtmlNode headerRow = doc.DocumentNode.SelectNodes(eventTableHeaderTag)[0];

            if (headerRow != null)
            {
                foreach (HtmlNode cell in headerRow.SelectNodes("th|td"))
                {
                    HtmlAttributeCollection attributes = cell.Attributes;

                    foreach (HtmlAttribute bookieCode in attributes.AttributesWithName(bookieTag))
                    {
                        // If bookie code is not already in the list
                        if (!bookieCodesList.Contains(bookieCode.Value))
                        {
                            bookieCodesList.Add(bookieCode.Value);
                        }
                    }
                }
            }

            HtmlNodeCollection eventRows = doc.DocumentNode.SelectNodes(eventTableRowTag);

            foreach (HtmlNode eventRow in eventRows)
            {
                string        name     = "";
                List <string> oddsList = new List <string>();

                HtmlAttributeCollection attributes = eventRow.Attributes;

                foreach (HtmlAttribute resultName in attributes.AttributesWithName(resultTag))
                {
                    name = resultName.Value;
                }

                foreach (HtmlNode cell in eventRow.SelectNodes("th|td"))
                {
                    attributes = cell.Attributes;

                    bool isNoBet = (cell.Attributes.Contains("class") && cell.Attributes["class"].Value.Contains(noBetTag));

                    if (!isNoBet)
                    {
                        foreach (HtmlAttribute odds in attributes.AttributesWithName(oddsTag))
                        {
                            oddsList.Add(odds.Value);
                        }
                    }
                    else
                    {
                        oddsList.Add("0");
                    }
                }

                results.Add(new Result(name, bookieCodesList, oddsList, bookmakers));
            }
        }
Exemplo n.º 2
0
        private void ReadEventDetails(HtmlDocument doc)
        {
            // Read event table for event details

            //HtmlNode eventTable = doc.DocumentNode.SelectNodes(eventTableTag)[0];

            try
            {
                foreach (HtmlNode eventTable in doc.DocumentNode.SelectNodes(eventTableTag))
                {
                    HtmlAttributeCollection attributes = eventTable.Attributes;

                    foreach (HtmlAttribute dateAttribute in attributes.AttributesWithName(dateTag))
                    {
                        dateString = dateAttribute.Value;
                    }

                    foreach (HtmlAttribute eventAttribute in attributes.AttributesWithName(eventTag))
                    {
                        eventName = eventAttribute.Value;
                    }

                    foreach (HtmlAttribute betTypeAttribute in attributes.AttributesWithName(betTag))
                    {
                        betType = betTypeAttribute.Value;
                    }

                    foreach (HtmlAttribute sportAttribute in attributes.AttributesWithName(sportTag))
                    {
                        sport = sportAttribute.Value;
                    }

                    foreach (HtmlAttribute sportBracketAttribute in attributes.AttributesWithName(sportBracketTag))
                    {
                        sportBracket = sportBracketAttribute.Value;
                    }
                }
            }
            catch
            {
            }

            if (dateString != "")
            {
                try
                {
                    eventTime = Convert.ToDateTime(dateString);
                    if (eventTime < DateTime.Now)
                    {
                        inPlay = true;
                    }
                }
                catch
                {
                }

                timeToEvent = eventTime - DateTime.Now;
            }
        }
Exemplo n.º 3
0
        public static bool AttributeExists(this HtmlAttributeCollection collection, string name, string value)
        {
            if (collection == null)
            {
                return(false);
            }

            var attr = collection.AttributesWithName(name)?.FirstOrDefault() ?? null;

            return(attr != null && attr.Value == value);
        }