萬盛學電腦網

 萬盛學電腦網 >> 網頁制作 >> 腳本Html教程 >> 從html代碼中獲取Img標簽

從html代碼中獲取Img標簽

  /// <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;
}

copyright © 萬盛學電腦網 all rights reserved