c# webbrowser.documentstream保存html文件

using System.IO;

 

 这段代码会出现乱码 gb2312 编码的网页存下后出现乱码

String path = "d:\\1.html";
StreamReader sr = new StreamReader(webBrowser1.DocumentStream, Encoding.GetEncoding("GBK"));
StreamWriter sw = new StreamWriter(path);
sw.Write(sr.ReadToEnd());
sw.Flush();
sw.Close();
sr.Close();

 

 

 

winform,主要应用与网页抓取时碰到的乱码问题

程序代码
System.IO.StreamReader streamReader = new System.IO.StreamReader(this.webBrowser1.DocumentStream, System.Text.Encoding.GetEncoding("gb2312"));
string strWebBrowserDocument = streamReader.ReadToEnd();
File.WriteAllText("1.html", strWebBrowserDocument,Encoding.UTF8);
streamReader.Close();

 

c# webbrowser.documentstream保存html文件

上一篇:windows2003 iis6.0 配置php5.4.37


下一篇:rust实战入门到进阶(1)