【问题标题】:How get one phrase from HTML by JSOUPJSOUP 如何从 HTML 中获取一个短语
【发布时间】:2015-01-23 18:04:12
【问题描述】:

例如我有 HTML 块:

<h2><a href="http://google.ru" style="text-decoration: underline;"><img src="http://any_image.jpg"/></a>some_text</h2>

我想得到单词“some_text”。如果我使用这样的代码:

Elements elements = doc.select("h2");

我会得到所有的代码。请帮忙,我是 JSOUP 的新手

【问题讨论】:

    标签: java html jsoup


    【解决方案1】:

    试试这个:

    String text = doc.select("h2").first().text();
    

    【讨论】:

      猜你喜欢
      • 2015-06-27
      • 1970-01-01
      • 1970-01-01
      • 2015-01-06
      • 1970-01-01
      • 2019-11-24
      • 2011-08-30
      • 2016-02-15
      • 2017-10-16
      相关资源
      最近更新 更多