private static void PrintMapStats(HtmlNode docNode, string mapID) { HtmlNode mapContent = docNode.SelectSingleNode("//div[@id=\"" + mapID + "-content\"]"); HtmlNodeCollection statTables = mapContent.SelectNodes(".//table[contains(@class, 'totalstats')]"); // flag+name, k-d, +/-, adr, kast,rating 2.0 string PLAYER_TEMP = "|{0,-50}|{1,7}|{2,4}|{3,5}|{4,6}|{5,12}|"; //PLAYER_TEMP's length when printed string border = new string('-', 91); foreach (HtmlNode teamTable in statTables) { StatTeam stats = GetStatsFromTable(teamTable); string fmt = String.Format(PLAYER_TEMP, stats.teamName, "K-D", "+/-", "ADR", "KAST", "Rating 2.0"); Console.WriteLine(border + "\n" + fmt + "\n" + border); foreach (StatPlayer player in stats.teamPlayers) { string formattedName = "[" + player.flag + "] " + player.name; fmt = String.Format(PLAYER_TEMP, formattedName, player.kd, player.plusMinus, player.adr, player.kast, player.rating); Console.WriteLine(fmt + "\n" + border); } Console.WriteLine(""); } }
private static StatTeam GetStatsFromTable(HtmlNode table) { StatTeam stats = new StatTeam(); HtmlNodeCollection rows = table.SelectNodes(".//tr"); HtmlNode header = rows[0]; stats.teamName = header.SelectSingleNode(".//a[contains(@class, 'teamName')]").InnerText; for (int i = 1; i < rows.Count; i++) { HtmlNode playerRow = rows[i]; StatPlayer player = new StatPlayer(); player.name = playerRow.SelectSingleNode(".//div[contains(@class, 'statsPlayerName')]").InnerText; player.flag = playerRow.SelectSingleNode(".//img[@class=\"flag\"]").GetAttributeValue("title", "no-flag"); player.kd = playerRow.SelectSingleNode(".//td[contains(@class, 'kd')]").InnerText; player.plusMinus = playerRow.SelectSingleNode("td[contains(@class, 'plus-minus')]").InnerText; player.adr = playerRow.SelectSingleNode("td[contains(@class, 'adr')]").InnerText; player.kast = playerRow.SelectSingleNode("td[contains(@class, 'kast')]").InnerText; player.rating = playerRow.SelectSingleNode("td[contains(@class, 'rating')]").InnerText; stats.teamPlayers.Add(player); } return(stats); }