试用WebClient读取网页

mac2022-06-30  71

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

转载于:https://www.cnblogs.com/KenBlove/articles/1331411.html

相关资源:数据结构—成绩单生成器
最新回复(0)