首页 > Windows开发 > 详细

c#获取网页源代码

时间:2015-08-13 12:00:43      阅读:218      评论:0      收藏:0      [点我收藏+]

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,根据流直接读取网页源代码

c#获取网页源代码

原文:http://www.cnblogs.com/binglab/p/4726694.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!