I'm trying to scrape a website for data using jsoup. But having some problems with getting some text.
Part of the html looks like this
<p class="time">9:00</p>
which i can grab fine using the line of code:
Document doc = Jsoup.connect(url).get();
doc.select("p.time").text());
but the next bit of html looks like this:
<p class="date"><strong>FRIDAY 27<sup>th</sup></strong> JULY 2012</p>
Which i'm not sure how to get. Using the line:
doc.select("p.date").text());
just gets me an empty string. I've tried variations of that (ie selecting "p.date" and then try date.select("strong")) but just keep coming up with a empty strings.
how do I go about getting that date text?
Unable to reproduce your problem.
Document doc = Jsoup.parse("<html><body><p class=\"date\"><strong>FRIDAY 27<sup>th</sup></strong> JULY 2012</p></body></html>");
String s = doc.select("p.date").text();
System.out.println(s);
This prints: "FRIDAY 27th JULY 2012"
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.