好记性不如烂笔头。

asp.net 正则获取网页所有a标签

        static void Main(string[] args)
        {
            WebClient wc = new WebClient();
            string result = wc.DownloadString("url");
            Regex reg = new Regex(@"(?is)<a(?:(?!href=).)*href=(['""]?)(?<url>[^""\s>]*)\1[^>]*>(?<text>(?:(?!</?a\b).)*)</a>");
            MatchCollection mc = reg.Matches(result);
            foreach (Match m in mc)
            {
                Console.WriteLine(m.Groups["url"].Value + " " + m.Groups["text"].Value);
            }
        }