只是想弄清楚如何从已经解析的信息中解析信息。
foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//div [@class=\"result-link\"]"))
{
if (node == null)
Console.WriteLine("debug");
else
{
//string h_url = node.Attributes["a"].Value;
Console.WriteLine(node.InnerHtml);
}
}
所以你可以看看我想用'string h_url'声明做什么。在“结果链接”div 类中有一个 href 属性,我试图获取 href 值。所以链接基本上。
似乎无法弄清楚。我尝试使用 Attributes 数组:
string h_url = node.Attributes["//a[@href].Value;
没有运气。