I am using the following to get a web page which works 开发者_开发知识库fine
    public static HtmlDocument GetWebPageFromUrl(string url)
    {
        var hw = new HtmlWeb();
        return hw.Load(url);
    }
But how to I spit the entire contents of the HTML out from the HtmlDocument into a string?
I tried HtmlDocument.ToString() but that doesn't give me all the HTML in the document? Any ideas?
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;
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论