简体   繁体   中英

How to get information using jsoup

I have this html

<td rowspan="3" class="event start"> <a href="/search/1065650;1/note">INFO1<br>DETAIL1 DETAIL2<br>INFO2</a> </td> 

how can I get INFO1 and INFO2 using jsoup??

Try something like that :

Document doc = Jsoup.connect(url).get();
Elements td=doc.select("td.event.start");
Elements a = td.first().getElementsByTag("a");
String [] words = a.text().split(" ");
System.out.println(words[0]+" "+words[3]);

Tested on:

 <!doctype html> <html> <body> <td rowspan="3" class="event start"> <a href="/search/1065650;1/note"> INFO1<br>DETAIL1 DETAIL2<br>INFO2 </a> </td> </body> </html> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM