HTML Agility Pack HtmlDocument Show All Html?

后端 未结 1 917
独厮守ぢ
独厮守ぢ 2020-12-06 09:42

I am using the following to get a web page which works fine

    public static HtmlDocument GetWebPageFromUrl(string url)
    {
        var hw = new HtmlWeb()         


        
相关标签:
1条回答
  • 2020-12-06 10:29

    DocumentNode.OuterHtml contains the full html:

    HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
    doc.Load("sample.html");
    string html = doc.DocumentNode.OuterHtml;
    

    In your example:

    public static string GetWebPageHtmlFromUrl(string url)
    {
        var hw = new HtmlWeb();
        HtmlDocument doc = hw.Load(url);
        return doc.DocumentNode.OuterHtml;
    }
    
    0 讨论(0)
提交回复
热议问题