读书人

怎么用正则表达式提取网页Meta 中 key

发布时间: 2013-01-17 10:28:55 作者: rapoo

如何用正则表达式提取网页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的代码呢?

读书人网 >C#

热点推荐