private static string InvestResource(IWebDriver webDrv, StreamWriter streamWriter, Dictionary <int, string> paths) { try { foreach (var path in paths) { webDrv.Navigate().GoToUrl(path.Value); Thread.Sleep(2000); var main = webDrv.FindElement(By.TagName(@"main")); var divElements = main.FindElements(By.TagName(@"div")); RoomInfo roominfo = new RoomInfo(); roominfo.Address = divElements[2].Text; roominfo.Price = divElements[9].Text.Replace("\r\n", string.Empty); roominfo.AddOn = divElements[14].Text; var strElements = Regex.Replace(main.Text, "<.*?>", string.Empty); var elements = strElements.Split(new string[] { "\r\n" }, StringSplitOptions.None); for (int i = 0; i < 18; i++) { var strElement = elements[i]; if (strElement.Contains(@"Let available date: ")) { roominfo.LetAvailableDate = strElement.Replace(@"Let available date: ", string.Empty); continue; } if (strElement.Contains(@"Let type: ")) { roominfo.LetType = strElement.Replace(@"Let type: ", string.Empty); continue; } if (strElement.Contains(@"Furnish type: ")) { roominfo.FurnishType = strElement.Replace(@"Furnish type: ", string.Empty); continue; } if (strElement == "PROPERTY TYPE") { roominfo.PropertyType = elements[++i]; continue; } if (strElement == "BEDROOMS") { roominfo.BedRoom = elements[++i].Substring(1); continue; } if (strElement == "BATHROOMS") { roominfo.BathRoom = elements[++i].Substring(1); continue; } if (strElement == "SIZE") { roominfo.Size = elements[++i]; continue; } } var aside = webDrv.FindElement(By.TagName(@"aside")); roominfo.MarkedBy = aside.FindElements(By.TagName(@"a"))[0].Text; streamWriter.WriteLine(roominfo.GetRoomInfo()); streamWriter.Flush(); } return(""); } catch (Exception err) { return(null); } }