WebClient WC = null;
WC = new WebClient();
WC.Credentials = CredentialCache.DefaultCredentials;
Byte[] PageData = WC.DownloadData(URL);
html = Encoding.UTF8.GetString(PageData);
WC.Dispose();
使用WebClient下载网页内容
本文介绍了一种利用C#中的WebClient类下载指定URL网页内容的方法。通过设置凭据并使用DownloadData方法获取页面数据,之后将字节数组转换为UTF-8编码的字符串。

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