예제 #1
0
        public static List <MockDraftPick> getMockDraft(HtmlAgilityPack.HtmlDocument doc, string pickDate)
        {
            List <MockDraftPick> mdpList = new List <MockDraftPick>();
            // This is still messy from debugging the different values.  It should be optimized.
            var  dn       = doc.DocumentNode;
            var  dns      = dn.SelectNodes("/html/body/div/div/div/table");
            var  attr     = dns[1].Attributes;
            var  attrs    = attr.ToArray();
            var  style    = attr.FirstOrDefault().Value;
            var  ss       = style.ToString();
            bool hasStyle = ss.IndexOf("background-image: linear-gradient", StringComparison.OrdinalIgnoreCase) >= 0;

            foreach (var node in dns)
            {
                var  nodeStyle   = node.Attributes.FirstOrDefault().Value.ToString();
                bool hasTheStyle = node.Attributes.FirstOrDefault().Value.ToString().IndexOf("background-image: linear-gradient", StringComparison.OrdinalIgnoreCase) >= 0;
                if (hasTheStyle)
                {
                    var           tr            = node.SelectSingleNode("tr");
                    MockDraftPick mockDraftPick = createMockDraftEntry(tr, pickDate);
                    mdpList.Add(mockDraftPick);
                }
            }
            var hasGradient = dns[1].Attributes.Contains("background-image");

            return(mdpList);
        }
예제 #2
0
        public static MockDraftPick createMockDraftEntry(HtmlNode tableRow, string pickDate)
        {
            var    childNodes = tableRow.ChildNodes;
            var    node1      = childNodes[1].InnerText; //pick number?
            string pickNumber = node1.Replace("\r", "")
                                .Replace("\n", "")
                                .Replace("\t", "")
                                .Replace(" ", "");
            var node3    = childNodes[3]; //team (and team image)?
            var teamCity = node3.ChildNodes[0].InnerText
                           .Replace("\r", "")
                           .Replace("\n", "")
                           .Replace("\t", "")
                           .TrimEnd();
            var    node5      = childNodes[5]; //Has Child Nodes - Player, School, Position, Reach/Value
            string playerName = node5.ChildNodes[1].InnerText
                                .Replace("\r", "")
                                .Replace("\n", "")
                                .Replace("\t", "")
                                .TrimEnd();
            string playerSchoolBeforeChecking = node5.ChildNodes[3].InnerText
                                                .Replace("\r", "")
                                                .Replace("\n", "")
                                                .Replace("\t", "")
                                                .TrimEnd(); // this may have a space afterwards.
            string playerSchool   = checkSchool(playerSchoolBeforeChecking);
            string playerPosition = node5.ChildNodes[5].InnerText
                                    .Replace("\r", "")
                                    .Replace("\n", "")
                                    .Replace("\t", "")
                                    .Replace(" ", "");
            string reachValue = node5.ChildNodes[9].InnerText
                                .Replace("\r", "")
                                .Replace("\n", "")
                                .Replace("\t", "")
                                .Replace(" ", "");


            MockDraftPick mdp = new MockDraftPick(pickNumber, teamCity, playerName, playerSchool, playerPosition, reachValue, pickDate);

            Console.WriteLine(mdp.round);
            Console.WriteLine(mdp.leagifyPoints);
            Console.WriteLine(mdp.pickNumber);
            Console.WriteLine(mdp.teamCity);
            Console.WriteLine(mdp.playerName);
            Console.WriteLine(mdp.school);
            Console.WriteLine(mdp.position);
            Console.WriteLine(mdp.reachValue);
            Console.WriteLine(mdp.state);
            return(mdp);
        }