开发者

WPF Save WebBrowser HTML

Does anyone (please) know how to do this? I 开发者_C百科thought that there would be an easy way to achieve this but can't find anything about saving the contents of WebBrowser HTML.


You might try something like this:

(Assuming C# 4 and WPF 4)

dynamic doc = webBrowser.Document;
var htmlText = doc.documentElement.InnerHtml;

Works for me...


Yous should use HttpWebRequest and HttpWebResponse objects. Simple sample (found in web, tested, working):

HttpWebRequest myWebRequest = (HttpWebRequest)HttpWebRequest.Create(@"http://www.[pagename].com");
myWebRequest.Method = "GET";

HttpWebResponse myWebResponse = (HttpWebResponse)myWebRequest.GetResponse();

StreamReader myWebSource = new StreamReader(myWebResponse.GetResponseStream());

string myPageSource = string.Empty;
myPageSource = myWebSource.ReadToEnd();
myWebResponse.Close();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜