如何获取某些html的所有图像源
本文关键字:html 图像 何获取 获取 | 更新日期: 2023-09-27 18:33:43
我用这个
string matchString = Regex.Match(sometext, "<img.+?src=['"'](.+?)['"'].+?>", RegexOptions.IgnoreCase).Groups[1].Value;
以获取图像 src。
但是我怎样才能得到我能找到的所有 src?
谢谢!
你应该使用Regex.Matchs而不是Match,你应该添加Multiline选项 我相信:
foreach (Match m in Regex.Matches(sometext, "<img.+?src=['"'](.+?)['"'].+?>", RegexOptions.IgnoreCase | RegexOptions.Multiline))
{
string src = m.Groups[1].Value;
// add src to some array
}