首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么用正则表达式提取网页Meta 中 keywords 的 content 值

2013-01-17 
如何用正则表达式提取网页Meta 中 keywords 的 content 值如何用正则表达式提取网页Meta 中 keywords 的 c

如何用正则表达式提取网页Meta 中 keywords 的 content 值
如何用正则表达式提取网页Meta 中 keywords 的 content 值.谢谢了急用,
我是这样写的,但是有的网页获取不到..很是郁闷,\

            string reg = "<meta name="keywords" content="(?<key>\\S+?)".+?/>";
            MatchCollection mc = Regex.Matches(str, reg, RegexOptions.IgnoreCase); //满足pattern的匹配集合
            textBox2.Text += "关键字结果为:";
            foreach (Match match in mc)
            {
                //   Console.WriteLine(match.ToString());
                GroupCollection gc = match.Groups;

                textBox2.Text += count + "\r\n";
                textBox2.Text += gc["key"].Value + "\r\n";

            }
大家帮我看看吧.谢了.

为什么不试试我3楼#3的代码呢?

热点排行