我试过了,我得到了一个错误你可能知道为什么吗?它给了我一个错误
var Webget = new HtmlWeb();
var doc = Webget.Load(earlyLink);
var ourNodes = doc.DocumentNode.SelectNodes(("//p[@class='product_note']"));
foreach (var node in ourNodes)
{
Console.WriteLine(node.GetDirectInnerText());
}```
This is the Error
未处理的异常。System.Net.WebException:连接被拒绝连接被拒绝
这只是您上一个问题的解决方案的变体。
查找所需节点的XPath是:
"//p[@class='product_note']"
然后获取内容使用:
node.GetDirectInnerText()
如果你做了很多这样的工作,你真的需要学习XPath和HtmlAgilityPack文档。