[英]Jsoup printing each <div> content in a separate line
I have been working on a web link with java jsoup library to extract some parts of it. 我一直在使用Java jsoup库处理Web链接以提取其中的某些部分。
This is the part which I work on it. 这是我要做的部分。
<div class="adv_side_price">
100,000 ريال
</div>
<div class="adv_side_price">
16,000 ريال
</div>
<div class="adv_side_price">
16,000 ريال
</div>
<div class="adv_side_price">
16,000 ريال
</div>
<div class="adv_side_price">
37,000 ريال
</div>
<div class="adv_side_price">
150,000 ريال
</div>
<div class="adv_side_price">
60,000 ريال
</div>
<div class="adv_side_price">
119,000 ريال
</div>
The output should be as following: 输出应如下所示:
100,000 100,000
19,500 19,500
37,000 37,000
150,000 150,000
60,000 60,000
119,000 119,000
10,000 10,000
I used the following code 我用下面的代码
Document doc = Jsoup.connect("https://www.bezaat.com/ksa/riyadh/cars/all/1").get();
System.out.println("Price"+doc.select("div.adv_side_price").text().replace("ريال",""));
But output gained as one line 但是输出却只有一条线
Price 100,000 19,500 37,000 150,000 60,000 119,000 10,000
Could someone possibly helps please 有人可以帮忙吗
Try printing content of each div using separate println
call like 尝试使用单独的
println
调用打印每个div的内容,例如
Document doc = Jsoup.connect("https://www.bezaat.com/ksa/riyadh/cars/all/1").get();
for (Element el : doc.select("div.adv_side_price"))
System.out.println(el.text().replace("ريال", ""));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.