如何使用C#保存webkitBrowser的HTML页面? [英] How to save HTML page Of webkitBrowser using C#?

查看:517
本文介绍了如何使用C#保存webkitBrowser的HTML页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的女士/先生,





我想永久保存WebkitBrowser的HTML页面。



请帮帮我。



谢谢

Mahendra Kumar Das

Dear Madam/Sir,


I want to save permanently HTML page of WebkitBrowser .

Please Help me.

Thanks
Mahendra Kumar Das

推荐答案

我不确定如果你想用C#下载页面的html,Webkit必须做什么,因为你可以使用HttpWebRequest类来做。



见下面的示例,它将下载html并永久将其保存到文件中:



Im not really sure what Webkit has to do if your wanting to download the html of a page in C# as you can do that using HttpWebRequest class.

See sample below, it will download the html and "permanently" save it to a file:

WebRequest req = HttpWebRequest.Create("http://codeproject.com");
            req.Method = "GET";

            string htmlstring;
            using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream()))
            {
                htmlstring = reader.ReadToEnd();
            }

            using (StreamWriter outfile = new StreamWriter(@"c:\temp\websitehtml.html"))
            {
                outfile.Write(htmlstring);
            }


这篇关于如何使用C#保存webkitBrowser的HTML页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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