//不能用 this.webBrowser.DocumentText 读取网页源代码,读出来是乱码
string url="http://www.yn-home.com";
this.webBrowser.Url = new System.Uri(url);
System.IO.StreamReader strm = new System.IO.StreamReader(this.webBrowser.DocumentStream, Encoding.GetEncoding("gb2312"));
string docment = strm.ReadToEnd();
// MessageBox.Show(strm.ReadToEnd());
// return;
本文介绍了一种利用C#中的WebBrowser控件结合StreamReader读取指定网址(如http://www.yn-home.com)的方法来获取网页源代码的技术实现细节。此方法通过设置WebBrowser控件的URL并使用正确的字符集(例如gb2312)来避免乱码问题。
2139





