Exemplo n.º 1
0
        //public static void GetNflTeams(TeamList teams)
        //{

        //    HtmlIterator teamPage = new HtmlIterator(WebUtility.GetNflURL().ToString());
        //    while (teamPage.GetNext("<h5 ><a href=\"http://www.espn.com/nfl/team/_/name/"))
        //    {
        //        Team te = new Team();
        //        te.teamName = teamPage.GetNextTagText("a");
        //        teamPage.GetNext("<h5 ><a href=\"/nfl/team/roster/_/name/");
        //        te.teamURL = "http://www.espn.com" + teamPage.GetNextAttributeValue("href");
        //        teams.Add(te);
        //        PlayerList playerList = new PlayerList();
        //        HtmlIterator t = new HtmlIterator(te.teamURL);
        //        if (!t.GetNext("COLLEGE")) continue;
        //        int endOfTable = t.HTML.IndexOf("</table>", t.StartIndex);
        //        while (t.StartIndex < endOfTable && t.StartIndex >= 0)
        //        {
        //            FootballPlayer player = new FootballPlayer();
        //            int dummy;
        //            if (int.TryParse(t.GetNextTagText("td"), out dummy))
        //                player.Number = dummy;
        //            player.Name = t.GetNextTagText("a");
        //            player.Position = t.GetNextTagText("td");
        //            if (int.TryParse(t.GetNextTagText("td"), out dummy))
        //                player.Age = dummy;
        //            player.Height = 0;
        //            string[] height = t.GetNextTagText("td").Split('-');
        //            for (int i = 0; i < height.Length; i++)
        //            {
        //                if (int.TryParse(height[i], out dummy))
        //                    player.Height += (12 * dummy) / (11 * i + 1);
        //            }
        //            if (int.TryParse(t.GetNextTagText("td"), out dummy))
        //                player.Weight = dummy;
        //            if (int.TryParse(t.GetNextTagText("td"), out dummy))
        //                player.Experience = dummy;
        //            else player.Experience = 0; // Rookie
        //            player.College = t.GetNextTagText("td");
        //            te.Players.Add(player);
        //        }
        //    }
        //}

        public static void GetNcaabTeams(TeamList teams)
        {
            HtmlIterator teamPage = new HtmlIterator(WebUtility.GetURL().ToString());

            while (teamPage.GetNext("<tr><td class='nowrap'"))
            {
                BasketballTeam te = new BasketballTeam();
                te.teamName = teamPage.GetNextAttributeValue("rel");
                te.teamURL  = "http://basketball.realgm.com" + teamPage.GetNextAttributeValue("href");
                teams.Add(te);
                BasketballPlayerList playerList = new BasketballPlayerList();
                HtmlIterator         t          = new HtmlIterator(te.teamURL + "rosters/");
                if (!t.GetNext("High School/Prep School"))
                {
                    continue;
                }
                int endOfTable = t.HTML.IndexOf("</tbody>", t.StartIndex);
                while (t.StartIndex < endOfTable && t.StartIndex >= 0)
                {
                    BasketballPlayer player = new BasketballPlayer();
                    int dummy;
                    if (int.TryParse(t.GetNextTagText("td"), out dummy))
                    {
                        player.Number = dummy;
                    }
                    else
                    {
                        continue;
                    }
                    player.Name     = t.GetNextTagText("a");
                    player.Class    = t.GetNextTagText("td");
                    player.Position = t.GetNextTagText("td");
                    player.Height   = 0;
                    string[] height = t.GetNextTagText("td").Split('-');
                    for (int i = 0; i < height.Length; i++)
                    {
                        if (int.TryParse(height[i], out dummy))
                        {
                            player.Height += (12 * dummy) / (11 * i + 1);
                        }
                    }
                    if (int.TryParse(t.GetNextTagText("td"), out dummy))
                    {
                        player.Weight = dummy;
                    }
                    player.BirthDate   = t.GetNextTagText("td");
                    player.BirthCity   = t.GetNextTagText("td");
                    player.Nationality = t.GetNextTagText("td");
                    player.HighSchool  = t.GetNextTagText("td");
                    te.Players.Add(player);
                }
            }
        }
Exemplo n.º 2
0
        private void _getsched(object o)
        {
            int index = (int)o;
            // HtmlIterator h_team = new HtmlIterator(((Team)o).teamURL), h;
            //  HtmlIterator h = new HtmlIterator("http://espn.go.com/college-football/team/schedule/"+((Team)o).teamURL.Substring(((Team)o).teamURL.IndexOf('_')));
            HtmlIterator h = new HtmlIterator("http://games.espn.go.com/tournament-challenge-bracket/2016/en/entry?entryID=" + (index + 1).ToString());

            Matrix[index] = 0;
            UInt64 mask = 0x4000000000000000;

            while (h.GetNext("class=\"slots\""))
            {
                h.GetNext("<div");
                if (h.GetNextAttributeValue("class").Contains("userPickable"))
                {
                    //Hasn't happened yet
                    h.GetNext("<span class=\"picked");
                    h.EndIndex = h.StartIndex;
                    if (h.GetNextAttributeValue("class").Contains("selectedToAdvance"))
                    {
                        Matrix[index] |= mask;
                    }
                }
                else
                {
                    //Already happened
                    h.GetNext("<span");
                    if (h.GetNextAttributeValue("class").Contains("selectedToAdvance"))
                    {
                        Matrix[index] |= mask;
                    }
                }
                mask >>= 1;
            }
            if (mask != 0)
            {
                Matrix[index] |= 0x8000000000000000;
            }
            System.Threading.Interlocked.Increment(ref fetch);
            m_Sem.Release();
        }
Exemplo n.º 3
0
        //private static void _getnflsched(object o)
        //{
        //    Team team = (Team)o;
        //    // HtmlIterator h_team = new HtmlIterator(((Team)o).teamURL), h;
        //    //  HtmlIterator h = new HtmlIterator("http://espn.go.com/college-football/team/schedule/"+((Team)o).teamURL.Substring(((Team)o).teamURL.IndexOf('_')));
        //    HtmlIterator h = new HtmlIterator(((FootballTeam)o).ScheduleUrl);
        //    while (h.GetNext("<li class=\"game-status\">"))
        //    {
        //        Matchup m = new Matchup();
        //        m.Home = !h.GetNextTagText("li").Contains("@");
        //        h.GetNext("<li class=\"team - name\"><a href=\"");
        //        m.Opponent = h.GetNextAttributeValue("href");
        //        h.GetNext("<li class=\"score\"><a href=\"");
        //        m.MatchupURL = "http:" + h.GetNextAttributeValue("href");
        //        HtmlIterator g = new HtmlIterator(m.MatchupURL);

        //        if (!g.GetNext("<h2>" + team.teamName)) continue;
        //        g.GetNext("<tbody");

        //        int endOfTable = g.HTML.IndexOf("/tbody", g.StartIndex);
        //        while (g.StartIndex < endOfTable)
        //        {
        //            string name = g.GetNextTagText("a");
        //            FootballPlayer p;
        //            if ((p = (FootballPlayer)team.Players[name]) != null)
        //            {
        //                int dummy;
        //                double doubleDummy;
        //                FootballPerformance perf = new FootballPerformance();
        //                perf.Status = g.GetNextTagText("td");
        //                g.GetNextTagText("td");
        //                if (double.TryParse(g.GetNextAttributeValue("rel"), out doubleDummy))
        //                    perf.Minutes = doubleDummy;
        //                string[] fg = g.GetNextTagText("td").Split('-');
        //                if (fg != null && fg.Length > 0)
        //                {
        //                    if (int.TryParse(fg[0], out dummy))
        //                        perf.FieldGoalsMade = dummy;
        //                    if (fg.Length > 1 && int.TryParse(fg[1], out dummy))
        //                        perf.FieldGoalsAttempted = dummy;
        //                }
        //                fg = g.GetNextTagText("td").Split('-');
        //                if (fg != null && fg.Length > 0)
        //                {
        //                    if (int.TryParse(fg[0], out dummy))
        //                        perf.ThreePointersMade = dummy;
        //                    if (fg.Length > 1 && int.TryParse(fg[1], out dummy))
        //                        perf.ThreePointersAttempted = dummy;
        //                }
        //                fg = g.GetNextTagText("td").Split('-');
        //                if (fg != null && fg.Length > 0)
        //                {
        //                    if (int.TryParse(fg[0], out dummy))
        //                        perf.FreeThrowsMade = dummy;
        //                    if (fg.Length > 1 && int.TryParse(fg[1], out dummy))
        //                        perf.FreeThrowsAttempted = dummy;
        //                }
        //                if (double.TryParse(g.GetNextAttributeValue("rel"), out doubleDummy))
        //                    perf.FIC = doubleDummy;
        //                if (double.TryParse(g.GetNextAttributeValue("rel"), out doubleDummy))
        //                    perf.OffensiveRebounds = (int)doubleDummy;
        //                if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
        //                    perf.DefensiveRebounds = dummy;
        //                g.GetNextAttributeValue("rel");
        //                if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
        //                    perf.Assists = dummy;
        //                if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
        //                    perf.PersonalFouls = dummy;
        //                if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
        //                    perf.Steals = dummy;
        //                if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
        //                    perf.Turnovers = dummy;
        //                if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
        //                    perf.Blocks = dummy;
        //                if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
        //                    perf.Points = dummy;
        //                perf.Matchup = m;
        //                perf.Player = p;
        //                p.Performances.Add(perf);
        //            }
        //        }

        //    }
        //    System.Threading.Interlocked.Increment(ref fetch);
        //}

        private static void _getncaabsched(object o)
        {
            BasketballTeam team = (BasketballTeam)o;
            // HtmlIterator h_team = new HtmlIterator(((Team)o).teamURL), h;
            //  HtmlIterator h = new HtmlIterator("http://espn.go.com/college-football/team/schedule/"+((Team)o).teamURL.Substring(((Team)o).teamURL.IndexOf('_')));
            HtmlIterator h = new HtmlIterator(((BasketballTeam)o).teamURL + "Schedule");

            while (h.GetNext("data-th=\"Opponent\""))
            {
                Matchup m = new Matchup();
                m.Home = !h.GetNextTagText("div").Contains("@");
                h.GetNext("<img");
                h.GetNext("</div>");
                h.ExtendToBeginningOfNext("</td>");
                if (h.Selection.Contains("<a href"))
                {
                    h.EndIndex = h.StartIndex;
                    m.Opponent = h.GetNextTagText("a");
                }
                else
                {
                    h.StartIndex += 6;
                    m.Opponent    = h.Selection;
                }
                bool win = false;
                int  awayScore = 0, homeScore = 0;
                h.GetNext("data-th=\"Result\"");
                string gameUrl = h.GetNextAttributeValue("href");
                h.GetPrevious("Result");
                string[] GameResult = h.GetNextTagText("a").RemoveWhiteSpace().Split(',', '-');
                if (GameResult.Length >= 3)
                {
                    win = GameResult[0].Contains("W");
                    int.TryParse(GameResult[1], out homeScore);
                    int.TryParse(GameResult[2], out awayScore);
                    if (m.Home)
                    {
                        //m.Opponent = away_team;
                        m.Win       = homeScore > awayScore;
                        m.TeamScore = homeScore;
                        m.OppScore  = awayScore;
                        // m.MatchupURL = h_team.Selection;
                    }
                    else
                    {
                        //m.Opponent = home_team;
                        m.Win       = homeScore < awayScore;
                        m.TeamScore = awayScore;
                        m.OppScore  = homeScore;
                        // m.MatchupURL = h_team.Selection;
                    }
                    m.ID = m.Opponent + m.TeamScore.ToString() + m.OppScore.ToString();
                    team.Matchups.Add(m);
                }
                HtmlIterator g = new HtmlIterator("http://basketball.realgm.com" + gameUrl);

                if (!g.GetNext("<h2>" + team.teamName))
                {
                    continue;
                }
                g.GetNext("<tbody");

                int endOfTable = g.HTML.IndexOf("/tbody", g.StartIndex);
                while (g.StartIndex < endOfTable)
                {
                    string           name = g.GetNextTagText("a");
                    BasketballPlayer p;
                    if ((p = (BasketballPlayer)team.Players[name]) != null)
                    {
                        int    dummy;
                        double doubleDummy;
                        BasketballPerformance perf = new BasketballPerformance();
                        perf.Status = g.GetNextTagText("td");
                        g.GetNextTagText("td");
                        if (double.TryParse(g.GetNextAttributeValue("rel"), out doubleDummy))
                        {
                            perf.Minutes = doubleDummy;
                        }
                        string[] fg = g.GetNextTagText("td").Split('-');
                        if (fg != null && fg.Length > 0)
                        {
                            if (int.TryParse(fg[0], out dummy))
                            {
                                perf.FieldGoalsMade = dummy;
                            }
                            if (fg.Length > 1 && int.TryParse(fg[1], out dummy))
                            {
                                perf.FieldGoalsAttempted = dummy;
                            }
                        }
                        fg = g.GetNextTagText("td").Split('-');
                        if (fg != null && fg.Length > 0)
                        {
                            if (int.TryParse(fg[0], out dummy))
                            {
                                perf.ThreePointersMade = dummy;
                            }
                            if (fg.Length > 1 && int.TryParse(fg[1], out dummy))
                            {
                                perf.ThreePointersAttempted = dummy;
                            }
                        }
                        fg = g.GetNextTagText("td").Split('-');
                        if (fg != null && fg.Length > 0)
                        {
                            if (int.TryParse(fg[0], out dummy))
                            {
                                perf.FreeThrowsMade = dummy;
                            }
                            if (fg.Length > 1 && int.TryParse(fg[1], out dummy))
                            {
                                perf.FreeThrowsAttempted = dummy;
                            }
                        }
                        if (double.TryParse(g.GetNextAttributeValue("rel"), out doubleDummy))
                        {
                            perf.FIC = doubleDummy;
                        }
                        if (double.TryParse(g.GetNextAttributeValue("rel"), out doubleDummy))
                        {
                            perf.OffensiveRebounds = (int)doubleDummy;
                        }
                        if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
                        {
                            perf.DefensiveRebounds = dummy;
                        }
                        g.GetNextAttributeValue("rel");
                        if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
                        {
                            perf.Assists = dummy;
                        }
                        if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
                        {
                            perf.PersonalFouls = dummy;
                        }
                        if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
                        {
                            perf.Steals = dummy;
                        }
                        if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
                        {
                            perf.Turnovers = dummy;
                        }
                        if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
                        {
                            perf.Blocks = dummy;
                        }
                        if (int.TryParse(g.GetNextAttributeValue("rel"), out dummy))
                        {
                            perf.Points = dummy;
                        }
                        perf.Matchup = m;
                        perf.Player  = p;
                        p.Performances.Add(perf);
                    }
                }
            }
            System.Threading.Interlocked.Increment(ref fetch);
        }