码迷,mamicode.com
首页 > 其他好文 > 详细

c#正则表达式采集数据

时间:2014-08-12 18:06:54      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:http   io   数据   for   ar   cti   line   amp   

 protected void Page_Load(object sender, EventArgs e)

  StringBuilder MyStringBuilder = new StringBuilder(); 

     WebRequest request = WebRequest.Create("http://www.dahuatech.com/news.aspx?type=1002");

     WebResponse response = request.GetResponse();

     StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));

  MatchCollection TitleMatchs = Regex.Matches(reader.ReadToEnd(), @"<img src=""images/5_02.jpg"" width=""2"" height=""3"">[\s]*<a href=""newsinfo.aspx[?]id=[\d]*&&type=1002"">([\s\S]*?)</a>", RegexOptions.IgnoreCase | RegexOptions.Multiline);

  foreach (Match NextMatch in TitleMatchs)           

  {

    //s += "<br>" + NextMatch.Groups[1].Value + NextMatch.Groups[2].Value;

    // tb1.Text += "\n" + NextMatch.Groups[1].Value+"\n" + NextMatch.Groups[2].Value;

    tb1.Text +=  NextMatch.Groups[1].Value.Trim()+"\n";            

  }

 

 }

c#正则表达式采集数据,布布扣,bubuko.com

c#正则表达式采集数据

标签:http   io   数据   for   ar   cti   line   amp   

原文地址:http://www.cnblogs.com/print/p/3907516.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!