标签:
c#获取网页源代码
1 /// <summary> 2 /// 获取html信息 3 /// </summary> 4 private string GetHtmlText(string url) 5 { 6 WebRequest req = WebRequest.Create(url); 7 WebResponse res = req.GetResponse(); 8 Stream resStream = res.GetResponseStream(); 9 StreamReader sr = new StreamReader(resStream, Encoding.UTF8); 10 string contentHtml = sr.ReadToEnd(); //读取网页的源代码 11 return contentHtml; 12 }
根据StreamReader,根据流直接读取网页源代码
标签:
原文地址:http://www.cnblogs.com/binglab/p/4726694.html