public void Parse(string scorecardHtml) { HtmlNode contentDiv = LoadHtml(scorecardHtml); HtmlNodeCollection tables = contentDiv.SelectNodes("./table"); if (tables.Count == 0) { Log.Warn("Invalid input text. This does not appear to be a CricketArchive scorecard page"); Log.Debug(scorecardHtml); return; } // Match #1 is the match info panel MatchInfoParser mip = new MatchInfoParser(_match, _finder); mip.Parse(tables[0]); if (tables.Count < 3) { return; } // Ensure all the players playing are in the data store CheckPlayersForInnings(tables[1]); CheckPlayersForInnings(tables[3]); InningsParser ip = new InningsParser(_match); // Match #2 and 3 are the batting and bowling respectively for the first innings _match.Innings.Add(ip.Parse(tables[1], tables[2])); // Match #4 and 5 are the batting and bowling respectively for the second innings if (tables.Count < 5) { return; } _match.Innings.Add(ip.Parse(tables[3], tables[4])); // Match #6 and 7 are the batting and bowling respectively for the third innings if (tables.Count < 7) { return; } _match.Innings.Add(ip.Parse(tables[5], tables[6])); // Match #8 and 9 are the batting and bowling respectively for the fourth innings if (tables.Count < 9) { return; } _match.Innings.Add(ip.Parse(tables[7], tables[8])); }
public void Parse(string scorecardHtml) { HtmlNode contentDiv = LoadHtml(scorecardHtml); HtmlNodeCollection tables = contentDiv.SelectNodes("./table"); if (tables.Count == 0) { Log.Warn("Invalid input text. This does not appear to be a CricketArchive scorecard page"); Log.Debug(scorecardHtml); return; } // Match #1 is the match info panel MatchInfoParser mip = new MatchInfoParser(_match, _finder); mip.Parse(tables[0]); if (tables.Count < 3) return; // Ensure all the players playing are in the data store CheckPlayersForInnings(tables[1]); CheckPlayersForInnings(tables[3]); InningsParser ip = new InningsParser(_match); // Match #2 and 3 are the batting and bowling respectively for the first innings _match.Innings.Add(ip.Parse(tables[1], tables[2])); // Match #4 and 5 are the batting and bowling respectively for the second innings if (tables.Count < 5) return; _match.Innings.Add(ip.Parse(tables[3], tables[4])); // Match #6 and 7 are the batting and bowling respectively for the third innings if (tables.Count < 7) return; _match.Innings.Add(ip.Parse(tables[5], tables[6])); // Match #8 and 9 are the batting and bowling respectively for the fourth innings if (tables.Count < 9) return; _match.Innings.Add(ip.Parse(tables[7], tables[8])); }