private static void DownloadSection(IWebElement sectionElement, int sectionIndex, string courseDir) { var sectionTitle = sectionElement.FindElement(By.CssSelector("p.title a")).Text; // Create a dir for the current section var sectionTitleWithIndex = String.Format("{0:D2}. {1}", sectionIndex, sectionTitle); var sectionFullPath = CourseDownloader.CreateDir(courseDir, sectionTitleWithIndex); Console.WriteLine(" Downloading section {0}: {1}", sectionTitleWithIndex, sectionFullPath); var clipElements = sectionElement.FindElements(By.CssSelector("div.content ul")); for (var i = 0; i < clipElements.Count; i++) { DownloadClip(clipElements[i], i + 1, sectionFullPath); } }
public static void Download() { Initialize(); var currentCourseTitle = Driver.Instance.FindElement(By.CssSelector("h1.course-title")).Text; Console.WriteLine("Downloading course: {0}", currentCourseTitle); // Create a dir for the current course var courseDir = CourseDownloader.CreateDir(PluralsaverSettings.Path, currentCourseTitle); Console.WriteLine("Into {0}", courseDir); var sectionElementList = Driver.Instance.FindElements(By.CssSelector("div.section")); Console.WriteLine("Number of sections: {0}", sectionElementList.Count); for (var sectionIndex = 0; sectionIndex < sectionElementList.Count; sectionIndex++) { var sectionElement = sectionElementList[sectionIndex]; DownloadSection(sectionElement, sectionIndex + 1, courseDir); } }