public static List <string> GetAllCourseNamestoList(HtmlNodeCollection allNodes, bool displayConsoleData) { List <string> listOfCourseNames = new List <string>(); foreach (var node in allNodes) { string refineHtml = node.InnerText; refineHtml = HTMLCodeSnippet.ReplaceSpecialCharacters(refineHtml); listOfCourseNames.Add(refineHtml); if (displayConsoleData) { Console.WriteLine(refineHtml); } } return(listOfCourseNames); }
public static List <CourseNameAndURL> GetAllCourseNamesAndURLstoList(HtmlNodeCollection allNodes, List <string> listOfCourseNames, List <string> listOfCourseURLs) { List <CourseNameAndURL> CousreNameURLList = new List <CourseNameAndURL>(); CourseNameAndURL CourseNameURL = new CourseNameAndURL(); foreach (var node in allNodes) { string refineHtml = node.InnerText; refineHtml = HTMLCodeSnippet.ReplaceSpecialCharacters(refineHtml); CourseNameURL.courseName = refineHtml; Console.WriteLine(refineHtml); CourseNameURL.cousreURL = node.GetAttributeValue("href", String.Empty); //listOfCourseURLs.Add(node.GetAttributeValue("href", String.Empty)); //Console.WriteLine(node.Attributes["href"].Value); Console.WriteLine(node.GetAttributeValue("href", String.Empty)); CousreNameURLList.Add(CourseNameURL); } return(CousreNameURLList); }