1
提取鏈接我新的HTML敏捷,我試圖讓下面的源代碼中的MP3鏈接:無法從一個div類使用HTML敏捷的XPath
<div id="fullPlayer">
<script type="text/javascript" src="http://stc.m.nixcdn.com/js/html5-player.0.1.js"></script>
<div class="player">
<div class="hide-html5">
<audio id="audio" controls="controls">
<source src="http://aredir.nixcdn.com/18c5db02a7804db01de320c1d34e5e6d/582c6bb4/NhacCuaTui217/Anh-HoQuynhHuong_3ycwf.mp3" type="audio/mpeg" />
</audio>
</div>
<div id="play" class="play control">
</div>
當我想,我無法訪問「hide-html5」節點,但對於「fullPlayer」可以。因此,src屬性不適用於圖像,在這種情況下,它是一個音頻鏈接。看看這個結構,「hide-html5」節點是「fullPlayer」的子節點,那麼我怎麼能從中提取mp3鏈接? 下面是我使用的代碼,但失敗了。
Dim doc As HtmlDocument = New HtmlWeb().Load("http://m.nhaccuatui.com/bai-hat/anh-ho-quynh-huong.hp7uaRRC5ID1.html")
Dim div As HtmlNode = doc.DocumentNode.SelectSingleNode("//div[@class='hide-html5']")
If Not div Is Nothing Then
Dim att As HtmlAttribute = div.Attributes("src")
MsgBox(att.Value)
Else
Msgbox("not accessible")
End if
是否需要任何特殊的代碼才能訪問html敏捷中的子節點?請分享。謝謝〜
謝謝你的回答。閱讀後我感到更加困惑。也許我需要在Xpath上學習更多,然後再回來解決這個問題。 :) –