我有一个html数据,如下所示:
<h4> Daily Prayer Powered by Hallow App: </h4>rn<center><iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=PLrM5hI29ZNuUmJ6wq15_-qUN8GAWxDs5l" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></center>rn<h3> The featured videos, the Queenship of Mary & Our Lady of Knock, can be found at the bottom of this page. </h3>rnrn<h4>First Reading - Adapted from 2Thes. 2:1-3A, 14-17 </h4>rn<p>Brothers and sisters: </p>rn<p>If you hear a statement or a letter supposedly from us that the Lord Jesus Christ is coming now, do not be alarmed. Do not let anyone trick you. He has called you through the Gospel to receive the glory of our Lord Jesus. So be strong and faithful to the traditions which you were taught by us, either orally or in writing. May our Lord Jesus Christ and God our Father, who loves us and encourages us and gives us hope, encourage you and strengthen your hearts to do every good work. </p>rnrn<h4>Psalm 96:10-13 </h4>rn<p>Say among the nations, "The LORD reigns! </p>rn<p> Yea, the world is established, it shall never be moved; </p>rn<p> he will judge the peoples with equity."</p>rn<p>Let the heavens be glad, and let the earth rejoice; </p>rn<p> let the sea roar, and all that fills it; </p>rn<p> let the field exult, and everything in it! </p>rn<p>Then shall all the trees of the wood sing for joy </p>rn<p> before the LORD, for he comes, </p>rn<p> for he comes to judge the earth. </p>rn<p>He will judge the world with righteousness, </p>rn<p> and the peoples with his truth. </p>rnrn<h4>Gospel - Adapted from Matthew 23:23-26 </h4>rn<p>Jesus said: </p>rn<p>"Great sadness to you, scribes and Pharisees, you hypocrites! You give valuable spices to the temple, but you do not give more important things - justice, and mercy, and faithfulness. You should have done these as well as the others. You are blind guides who focus on religious details but ignore large sins. You appear clean on the outside, but inside you are full of selfishness. Blind Pharisee, first be clean on the inside, and the outside will also be clean."</p>rnrn<h4>Featured Videos:</h4>rn<h3> The Queenship of Mary </h3>rn<p> Watch the Catholic Brain video the Queenship of Mary below: </p>rn<div class="video-responsive"><iframe src="https://player.vimeo.com/video/447623879" width="640" height="360" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe></div>rn<p>The Catholic Brain lesson the Queenship of Mary can be <a href="https://www.catholicbrain.com/edu-lesson/1053474/video/the-queenship-of-mary" target="_blank">found here</a>.</p>rn<h3> Our Lady of Knock </h3>rn<p> Watch the Catholic Brain video Our Lady of Knock below: </p>rn<div class="video-responsive"><iframe src="https://player.vimeo.com/video/447228009" width="640" height="360" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe></div>rn<p>The Catholic Brain lesson Our Lady of Knock can be <a href="https://www.catholicbrain.com/edu-lesson/1051554/video/our-lady-of-knock" target="_blank">found here</a>.</p>
在这个数据上有2个vimeo视频URL,如下所示:
- https://player.vimeo.com/video/447623879
- https://player.vimeo.com/video/447228009
我需要将视频URL单独解析为字符串数组。可能有一个或多个视频URL,我需要一个数组上的所有视频URL。如何使用c#代码从HTML数据中解析这些数据?
更新:
我尝试了下面的代码,得到了初始的iframe-src链接。但是我的数据上还有一些其他的src链接。如何获取所有iframe-src链接?
string src = Regex.Match(description, "<iframe.+?src=["'](.+?)["'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
Debug.WriteLine("src:>>" + src);
我已经使用以下代码解析了vide链接:
List<string> vimeoVideoList = new List<string>();
var allMatches = Regex.Matches(description, "<iframe.+?src=["'](.+?)["'].*?>", RegexOptions.IgnoreCase);
foreach (Match match in allMatches)
{
string sourceData = Regex.Match(match.ToString(), "<iframe.+?src=["'](.+?)["'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
vimeoVideoList.Add(sourceData);
}