我試圖從YouTube的搜索結果頁面檢索所有視頻ID。YouTube HTML敏捷包C#
每個結果都有這樣的代碼:
<a href="/watch?v=aYIC-ebAD3o" class="ux-thumb-wrap result-item-thumb">
<span class="video-thumb ux-thumb-128 ">
<span class="clip">
<img onload="tn_load(5)" alt="Thumbnail" src="//i2.ytimg.com/vi/aYIC-ebAD3o/default.jpg" >
</span>
</span>
<span class="video-time">4:16</span>
<span dir="ltr" class="yt-uix-button-group addto-container short video-actions" data-video-ids="aYIC-ebAD3o" data-feature="thumbnail">
<button type="button" class="start master-sprite yt-uix-button yt-uix-button-short yt-uix-tooltip" onclick=";return false;" title="" data-button-action="yt.www.addtomenu.add" role="button" aria-pressed="false">
<img class="yt-uix-button-icon yt-uix-button-icon-addto" src="//s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="">
<span class="yt-uix-button-content">
<span class="addto-label">Add to</span>
</span>
</button>
<button type="button" class="end yt-uix-button yt-uix-button-short yt-uix-tooltip yt-uix-button-empty" onclick=";return false;" title="" data-button-menu-id="shared-addto-menu" data-button-action="yt.www.addtomenu.load" role="button" aria-pressed="false">
<img class="yt-uix-button-arrow" src="//s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="">
</button>
</span>
<span class="video-in-quicklist">Added to queue </span>
</a>
<div class="result-item-main-content">
,我試圖分析出「數據的視頻ID爲」類的數據。用HTML Agility Pack做這個最好的方法是什麼?
我已經試過這樣:
foreach(HtmlNode node in doc.DocumentNode.
SelectNodes("//span[@class='data-video-ids']"))
{
string text = node.InnerText;
lblTest2.Text += text + Environment.NewLine;
}
任何想法?
它的作品,但它不檢索我後的信息。我希望爲aYIC-ebAD3o,但相反返回添加到 – mintuz 2011-03-15 18:14:59
請看到更新的答案:) – 2011-03-15 18:59:38