WebClient读取网页


WebClient client = new WebClient();
Stream stream
= client.OpenRead("http://www.microsoft.com/");
StreamReader sr
= new StreamReader(stream, System.Text.Encoding.UTF8);
string str = sr.ReadLine();
string returnvalue = string.Empty;
while (str != null)
{
returnvalue
+= str;
str
= sr.ReadLine();
}

 

当然WebClient远比这个强大,更多功能查看Msdn:http://msdn.microsoft.com/zh-cn/library/system.net.webclient(VS.80).aspx

你可能感兴趣的:(client)