internal void GetNode(HtmlNode node, List <GitRow> gitRows) { GitRow rowFile = new GitRow(); HtmlNode item = node.ChildNodes.SelectMany(a => a.Attributes).Where(a => a.Value == "rowheader").FirstOrDefault().OwnerNode; HtmlNode itemSpan = item.ChildNodes.ToList().Where(a => a.Name == "span").FirstOrDefault(); if (itemSpan == null) { return; } rowFile.Name = itemSpan.InnerText; rowFile.Url = itemSpan.ChildNodes[0].GetAttributes().Where(a => a.Name == "href").FirstOrDefault().Value; Console.WriteLine(rowFile.Url); if (node.ChildNodes.SelectMany(a => a.Attributes).SelectMany(a => a.OwnerNode.ChildNodes).SelectMany(a => a.Attributes).Where(a => a.Value == "Directory").ToList().Count > 1) { rowFile.IsDirectory = true; GetNodesRowHeader("https://github.com/" + rowFile.Url, gitRows); } else { rowFile = GetFileInformation(rowFile); gitRows.Add(rowFile); } }
internal GitRow GetFileInformation(GitRow row) { try { var result = Task.Run(() => DownloadTools.DownloadFile("https://raw.githubusercontent.com/" + row.Url.Replace("blob", ""))).Result; string converted = Encoding.UTF8.GetString(result, 0, result.Length); row.Length = result.Length; row.Extension = row.Name.Split('.')[row.Name.Split('.').Length - 1]; row.TotalLines = converted.Split('\n').Length; return(row); } catch { return(row); } }