Демонстрация работы с Lenta.Ru
Tab Tab1 = instance.ActiveTab;
//Отрабатываем новостные блоки первого типа
HtmlElementCollection colTime1 = Tab1.FindElementsByXPath("//time[@class='g-time']");
project.SendWarningToLog ("Новостных блоков первого типа: " + colTime1.Count);
foreach (HtmlElement elTime1 in colTime1.Elements) {
string strTime = elTime1.GetAttribute("InnerHtml");
string strTitle = elTime1.FindChildByXPath(".//parent::a[1]",0).GetAttribute("InnerHtml");
strTitle = Regex.Replace(strTitle, @"<.*>", String.Empty); //Убираем HTML-теги
project.SendInfoToLog (strTime + " - " + strTitle.Replace(" ", " "));
}
//Отрабатываем новостные блоки второго типа (получаем кучу значений времени без названия новости)
HtmlElementCollection colTime2 = Tab1.FindElementsByXPath("//span[@class='time']");
project.SendWarningToLog ("Новостных блоков второго типа: " + colTime2.Count);
foreach (HtmlElement elTime2 in colTime2.Elements) {
string strTime = elTime2.GetAttribute("InnerHtml");
string strTitle = elTime2.FindChildByXPath(".//ancestor::div[contains(@class, 'item news')]/descendant::a",0).GetAttribute("InnerHtml");
project.SendInfoToLog (strTime + " - " + strTitle.Replace(" ", " "));
}