HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); // создание объекта
var template_html = project.Variables["Htnl_Code"].Value; // грузим наш код из гет-запроса http://hotline.ua/adult-pepelnicy/brasstico-4114/discussion/
// условие xpath
var var_xpath1 = @"//ul[contains(@class, 'breadcrumbs cell-')]/li[2]/a";
doc.LoadHtml(template_html); // грузим DOM текст (из переменной template_html) в объект doc
var Nodes_list_1 = doc.DocumentNode.SelectSingleNode(var_xpath1); // получаем <a href="/adult/">Товары для взрослых</a>
if (Nodes_list_1 != null)
{
project.Variables["Kategoria"].Value = Nodes_list_1.InnerText; // получаем: Товары для взрослых
project.Variables["Kategoria_href"].Value = Nodes_list_1.GetAttributeValue("href", ""); // получаем: /adult/
}
else
{
project.SendInfoToLog("не нашли елемент", true);
project.Variables["Kategoria"].Value = ""; // обнуляем значение
project.Variables["Kategoria_href"].Value = ""; // обнуляем значение
}
return "ok";