如何在本地驱动器中保存Web浏览器内容 [英] how to save web browser content in local drive

查看:83
本文介绍了如何在本地驱动器中保存Web浏览器内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发通过Web浏览器控件显示网页的应用程序。在单击保存按钮的同时,带有图像的网页应存储在本地存储中。它应该以.html格式保存。

请任何人解释如何做和给出解决方案。



这里是我的代码



WebRequest request = WebRequest.Create(txtURL.Text);

WebResponse response = request.GetResponse();

Stream data = response.GetResponseStream() ;

string page = String.Empty;

使用(StreamReader sr = new StreamReader(data))

{

page = sr.ReadToEnd();

}

先谢谢..

I am developing application which am showing web pages through web browser control. While am clicking save button,the web page with images should be store in local storage. it should be save in .html format.
please any one explain how to do and give solution.

here is my code

WebRequest request = WebRequest.Create(txtURL.Text);
WebResponse response = request.GetResponse();
Stream data = response.GetResponseStream();
string page = String.Empty;
using (StreamReader sr = new StreamReader(data))
{
page = sr.ReadToEnd();
}
Thanks in Advance..

推荐答案

写在保存按钮点击事件下,



Write this under save button click event,

File.WriteAllText(path, browser.Document.Body.Parent.OuterHtml, Encoding.GetEncoding(browser.Document.Encoding));





Body.parent 将保存整个页面而不是保存只有 部分....



就是这样,



Body.parent will save whole the page instead of saving only part....

that's it,


这篇关于如何在本地驱动器中保存Web浏览器内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆