htmlagilitypack - remove script and style?

前端 未结 3 1729
走了就别回头了
走了就别回头了 2020-11-29 04:32

Im using the following method to extract text form html:

    public string getAllText(string _html)
    {
        string _allText = \"\";
        try
                


        
3条回答
  •  [愿得一人]
    2020-11-29 04:52

    You can do so using HtmlDocument class:

    HtmlDocument doc = new HtmlDocument();
    
    doc.LoadHtml(input);
    
    doc.DocumentNode.SelectNodes("//style|//script").ToList().ForEach(n => n.Remove());
    

提交回复
热议问题