public static string[,] Parse(ReplParserCfg cfg) { var ModuleCfg = ReplacementsModuleConfig.Get(); string html = HTMLLoader.Load(cfg.GetRequest(), ModuleCfg.ReplacementsString); List <string> trArray = new List <string>(); while (html.IndexOf("<tr>", StringComparison.Ordinal) != -1) { int start = html.IndexOf("<tr>", StringComparison.Ordinal); int finish = html.IndexOf("</tr>", StringComparison.Ordinal); trArray.Add(html.Substring(start + 4, finish - 4)); html = html.Remove(start, finish + 5); } string[,] DataArray = new string[trArray.Count, 6]; for (int i = 0; i < trArray.Count; i++) { for (int j = 0; j < 6; j++) { int start = trArray[i].IndexOf("<td>", StringComparison.Ordinal); int finish = trArray[i].IndexOf("</td>", StringComparison.Ordinal); DataArray[i, j] = trArray[i].Substring(start + 4, finish - 4); trArray[i] = trArray[i].Remove(start, finish + 5); } } return(DataArray); }
static void Main(string[] args) { ReplParserCfg cfg = new ReplParserCfg( dateTimeStart: new DateTime(2020, 09, 10), dateTimeEnd: new DateTime(2020, 09, 20), group: "075-18-1"); var replacements = Parser.GetReplacements(cfg); foreach (var item in replacements) { Console.WriteLine($"Date: {item.Date}"); Console.WriteLine($"Group: {item.Group}"); Console.WriteLine($"Lection: {item.Lection}"); Console.WriteLine($"Lecture Room: {item.LectureRoom}"); Console.WriteLine($"Para: {item.Para}"); Console.WriteLine($"Teacher: {item.Teacher}"); Console.WriteLine(); } }
public static List <Replacement> GetReplacements(ReplParserCfg Config) { List <Replacement> replacements = new List <Replacement>(); string[,] arr = Engine.ReplacementsParserEngine.Parse(Config); for (int i = 0; i < arr.GetLength(0); i++) { replacements.Add ( new Replacement() { Date = arr[i, 0], Para = arr[i, 1], Group = arr[i, 2], Lection = arr[i, 3], Teacher = arr[i, 4], LectureRoom = arr[i, 5] } ); } return(replacements); }