本帖最后由 yyy252999822 于 2012-07-09 18:15:22 编辑

解决方案 »

  1.   

    string s = File.ReadAllText(Server.MapPath("~/test.txt"), Encoding.GetEncoding("gb2312"));
    MatchCollection matches = Regex.Matches(s, @"(?is)<a href=""(?<href>[^""]+)"" class=""Info""[^>]*>(?<text>.+?)</a>");
    foreach (Match match in matches)
    {
    Response.Write(match.Groups["href"].Value + "<br/>");
    Response.Write(match.Groups["text"].Value + "<br/><br/>");
    }
      

  2.   


    string str =@"你的Html源码";
            MatchCollection matches = Regex.Matches(str, @"(?is)<a\b[^>]*?href=""(?<href>[^""]*?)""[^>]*?class=""Info""[^>]*?>(?<Content>.*?)</a>");
    Dcitionary<string,string> dic=new Dcitionary<string,string>();
            foreach (Match m in matches)
            {
                dic.Add(m.Groups["href"].Value ,m.Groups["Content"].Value);//dic就是你要的href和内容
            }