如何获取某些html的所有图像src [英] How to get all Images src's of some html
本文介绍了如何获取某些html的所有图像src的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用这个
string matchString = Regex.Match(sometext, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase).Groups[1].Value;
获取图像src.
但是我如何才能获得我能找到的所有src?
But how do I can get all src what I can find?
谢谢!
推荐答案
您应该使用Regex.Matches而不是Match,并且应该添加Multiline选项,我相信:
You should use Regex.Matches instead of Match, and you should add the Multiline option I believe:
foreach (Match m in Regex.Matches(sometext, "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase | RegexOptions.Multiline))
{
string src = m.Groups[1].Value;
// add src to some array
}
这篇关于如何获取某些html的所有图像src的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文