try
{
//get date from web url
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Download the Web resource and save it into a data buffer.
byte[] myDataBuffer = myWebClient.DownloadData (this.textBox2.Text);
// Display the downloaded data.
//string download = System.Text.Encoding.ASCII.GetString(myDataBuffer);
string download = System.Text.Encoding.GetEncoding("GB2312").GetString(myDataBuffer);
richTextBox1.Text=download;
}
catch(Exception _e)
{
MessageBox.Show(_e.Message);
}
How to grab web page in chinese
最新推荐文章于 2022-01-18 14:14:45 发布
博客展示了一段代码,利用WebClient从网页URL下载数据。创建WebClient实例后,使用DownloadData方法将网页资源下载到字节数组,再将字节数组转换为字符串并显示。同时使用try-catch块捕获可能出现的异常。
3297

被折叠的 条评论
为什么被折叠?



