萬盛學電腦網

 萬盛學電腦網 >> 網頁制作 >> Html5 >> 如何從html代碼中獲取Img標簽

如何從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;
}
以上就是我們給大家介紹的如何從html代碼中獲取Img標簽,希望大家繼續關注本網站。

copyright © 萬盛學電腦網 all rights reserved