0
<td>
<span class="movie_info_actors">
<a href="/?actor_name=Billy Connolly">Billy Connolly</a>
<a href="/?actor_name=Craig Ferguson">Craig Ferguson</a>
<a href="/?actor_name=Emma Thompson">Emma Thompson</a>
<a href="/?actor_name=John Ratzenberger">John Ratzenberger</a>
<a href="/?actor_name=Julie Walters">Julie Walters</a>
<a href="/?actor_name=Kelly Macdonald">Kelly Macdonald</a>
<a href="/?actor_name=Kevin McKidd">Kevin McKidd</a>
<a href="/?actor_name=Patrick Doyle">Patrick Doyle</a>
<a href="/?actor_name=Robbie Coltrane">Robbie Coltrane</a>
<a href="/?actor_name=Sally Kinghorn">Sally Kinghorn</a>
</span>
</td>

我正在尝试提取演员名称,然后使用 JSoup 用逗号分隔名称。例如:比利·康诺利、克雷格·弗格森、艾玛·汤普森

这是我的代码:

String Actor = E.select("span.movie_info_actors").text();
System.out.println(Actor + ", " );
4

1 回答 1

1

我认为应该是

Elements actors = E.select("span.movie_info_actors > a");
StringBuffer sb = new StringBuffer();
for (Element actor : actors) {
    sb.append(actor.text());
}
System.out.println(sb.toString());
于 2012-07-08T04:18:00.560 回答