/// <summary> /// Current Ministers Web Page Parser. /// </summary> public void GetHtmlGabinet() { //Web Page address var url = ConstantsModel.urlGabinet; //Browser used for the webpage insteractions. PhantomJSDriver driver = new PhantomJSDriver(); try { //Load a webpage in the current browser window. driver.Navigate().GoToUrl(url); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(4)); //Loads the HTML from the driver/browser. HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(driver.PageSource); //Gets the root node by its "div" descendants. var GabinetHTML = wait.Until(x => doc.DocumentNode.Descendants("div") .Where(node => node.GetAttributeValue("id", "") .Equals("pagebody")).ToList()); //Gets the name and headshot of the ministers by "h3" descendants. NameList = wait.Until(x => GabinetHTML[0].Descendants("h3") .Where(node => node.GetAttributeValue("class", "") .Contains("top-padding")).ToList()); //Gets the ttiles/bio of the ministers by "h3" descendants. TitleList = wait.Until(x => GabinetHTML[0].Descendants("p") .Where(node => node.GetAttributeValue("class", "") .Equals("clearfix")).ToList()); GabinetList = NameList.Concat(TitleList).ToList(); } catch (Exception) { throw; } finally { driver.Quit(); } }