从html代码中获取Img标签
发布时间:2015-05-12 来源:查字典编辑
摘要://////获取Img标签//////截获到的html代码///publicstaticListGetPadImg(stringhtmlTe...
/// <summary>
/// 获取Img标签
/// </summary>
/// <param name="htmlText">截获到的html代码</param>
/// <returns></returns>
public static List<string> GetPadImg(string htmlText)
{
List<string> list = new List<string>();
Regex regImg = new Regex(@"<imgb[^<>]*?bsrc[strn]*=[strn]*[""']?[strn]*(?<imgUrl>[^strn""'<>]*)[^<>]*?/?[strn]*>", RegexOptions.IgnoreCase);
MatchCollection mc = regImg.Matches(htmlText);
foreach (Match m in mc)
{
list.Add(m.Groups["imgUrl"].Value); //获取Img标签
}
return list;
}