【发布时间】:2014-08-24 12:36:56
【问题描述】:
大家好,我正在尝试在 HTML 文件中选择标签“”,但它在这里不起作用是该网站的来源:
</div><p><a href="http://www.pinoyfitness.com/wp-content/uploads/2014/03/sofitel-manila-half-marathon-2014-poster.jpg"><img src="http://www.pinoyfitness.com/wp-content/uploads/2014/03/sofitel-manila-half-marathon-2014-poster-540x783.jpg" alt="sofitel-manila-half-marathon-2014-poster" width="540" height="783" class="aligncenter size-medium wp-image-32747" /></a></p>
<p>Introducing the Manila Half Marathon happening on August 17, 2014 at the SM Mall of Asia Grounds. This race is for the benefit of the children of <a href="http://www.virlanie.org/" rel="nofollow" target="_blank">Virlanie</a></p>
<p><font size="3"><strong>Sofitel Manila Half-Marathon 2014</strong></font><br />
August 17, 2014 @ 3AM<br />
SM Mall of Asia<br />
5K/10K/21K<br />
Organizer: RunRio</p>
<p><strong>Registration Fees:</strong><br />
21K – P950<br />
10K – P850<br />
5K – P750</p>
这是我目前的工作:
doc = Jsoup.connect("http://www.pinoyfitness.com/2014/03/manila-half-marathon-august-17-2014/").timeout(0).get();
Element bod = doc.body();
Elements info = bod.select("br");
String textString = info.text();
System.out.println(textString);
我正在尝试使用“
”检索 html 代码,以便我可以轻松地对其进行拆分和格式化。
但是当我选择元素“P”时,它会打印所有不包括“
”的文本,例如“介绍 2014 年 8 月 17 日在 SM 亚洲购物中心举行的马尼拉半程马拉松比赛。这场比赛为 Virlanie Sofitel Manila Half-Marathon 2014 年 8 月 17 日 @ 3AM SM Mall of Asia 5K/10K/21K 组织者的孩子们的利益而设”
我是 JSOUP 的新手,所以如果遇到 newbee 错误或类似的问题,请放轻松。提前致谢。
【问题讨论】:
-
标签
<br/>似乎没那么有用。您究竟要检索什么内容? -
我正在尝试检索这样的内容:介绍 2014 年 8 月 17 日在 SM Mall of Asia Grounds 举行的马尼拉半程马拉松赛。这场比赛是为了 2014 年索菲特马尼拉半程马拉松的孩子们的利益
”,所以我可以用
将他们分开,对吗?@Reimeus -
请将其添加到问题本身 - 使用 Edit 链接
-
@Reimeus 我在那里添加了它:D
标签: java html-parsing jsoup