如何用jsoup获得param值?

时间:2012-12-17 22:03:51

标签: java android jsoup

我正在尝试用jsoup获得param值,但我无法实现这一点。

这是HTML示例:

<object id="a5514fbc4f070b58cfbfb2a17ad3011a" name="a5514fbc4f070b58cfbfb2a17ad3011a" type="application/x-shockwave-flash" data="http://player.sambatech.com.br/current/2.0.57/profiles/samba/sambaPlayer.swf" width="620" height="410">
<param name="flashvars" value="http://webcast.sambatech.com.br/80479D/origin1/account/143/3/2012-12-14/video/89903bb228d0af488d9dbb1228c3728a/121412AlbertoAcostaSeguridad.mp4">
</object>

这是我到目前为止所尝试过的,但没有运气:

Document doc = Jsoup.connect(providerUrl).get();
Element p_un = doc.select("param[name=flashvars]").first();
String v = p_un.attr("value");

我需要帮助。

1 个答案:

答案 0 :(得分:0)

您可以使用val()方法简单地访问该值。

Document doc = Jsoup.connect(providerUrl).get();
// Simple selector. If you wanna get the particular param, 
// change the selector to ("#a5514fbc4f070b58cfbfb2a17ad3011a > param")
Element el = doc.select("param").first();
String value = el.val();