艺海无涯,学无止境。欢迎一起探讨技术和人生,了解我

WebClient用法,用WebClient下载网页内容

private string GetHTML()
{
    System.Net.WebClient client = new WebClient();
    Stream strm = client.OpenRead("http://www.mayb.cn");
    StreamReader sr = new StreamReader(strm);
    string line;
    StringBuilder strB = new StringBuilder();
    while ((line = sr.ReadLine()) != null)
    {
        strB.Append(line);
    }
    strm.Close();
    return strB.ToString();
}