gpt4 book ai didi

java - 使用 JSoup 解析音频 Src

转载 作者:行者123 更新时间:2023-12-01 11:42:08 25 4
gpt4 key购买 nike

我正在尝试解析以下代码并尝试从 Audio 元素中提取 src 属性。

<div id="jquery_jplayer_1" class="jp-jplayer" style="width: 0px; height: 0px;">
<img id="jp_poster_0" style="width: 0px; height: 0px; display: none;">
<audio id="jp_audio_0" preload="none" src="http://www.testurl.com/mp3embed-zg3t2s8n2ofl.mp3">
</audio>
</div>

我尝试使用以下代码解析它,但没有成功

  Element link = doc.select("audio").first();

  Element link = doc.select("#jp_audio_0");

最佳答案

这应该可以解决问题:

String html = \\your html..
Document doc =Jsoup.parseBodyFragment(html);

//Selects first "audio" element with id of "jp_audio_0" and gets the "src" attribute.
<b>String src = doc.select("audio#jp_audio_0").first().attr("src");</b>

System.out.println(src);

关于java - 使用 JSoup 解析音频 Src,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29439947/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com