如何以 html 形式复制位于 div 中的文本

How can I copy the text that is located in a div in a form html

我试过了,但出现错误,您知道为什么吗? 它给我一个错误

            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 文档。