c#正则表达式采集数据

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";

  }

}

上一篇:echarts的使用


下一篇:hbase学习(二)hbase单机和高可用完全分布式安装部署