110,534
社区成员
发帖
与我相关
我的任务
分享
WebClient MyWebClient = new WebClient();
MyWebClient.Credentials = CredentialCache.DefaultCredentials;//获取或设置用于向Internet资源的请求进行身份验证的网络凭据
Byte[] pageData = MyWebClient.DownloadData("http://rate.taobao.com/user-rate-d0b16a349ceaa2c738aff0a5deccbdd0.htm"); //从指定网站下载数据
Console.WriteLine(Encoding.Default.GetString(pageData));//在控制台输入获取的内容
Console.ReadLine();
public static void DownloadString (string address)
{
WebClient client = new WebClient ();
string reply = client.DownloadString (address);
Console.WriteLine (reply);
}
//测试没什么问题
string str = System.Text.Encoding.Default.GetString(new System.Net.WebClient().DownloadData("http://rate.taobao.com/user-rate-d0b16a349ceaa2c738aff0a5deccbdd0.htm"));