I have done a lot of research, but I haven't got any success in this. I want to fetch comments on a specific post. I thought this site will surely help me out in this.
I did some code for the same but it is printing the main post, my requirement is to fetch the comments over a specific post. In this code I have used jsoup
library.
Elements hiddenElements = doc.select("code.hidden_elem");
for (Element hidden : hiddenElements) {
for (Node child : hidden.childNodesCopy()) {
if (child instanceof Comment) {
hidden.append(((Comment) child).getData());
}
}
}
Elements articles = doc.select("div[role=article]");
for (Element article : articles) {
if (article.select("span.userContent").size() > 0) {
String text = article.select("span.userContent").text();
String imgUrl = article.select("div.photo img").attr("abs:src");
System.out.println(String.format("%s\n%s\n\n", text, imgUrl));
}
}
Help in this will be appreciated. :)