I'm trying to use reddit.com/r/subreddit/random
to get a random link from /r/nocontext. However, it seems to bring me to the same link repeatedly should I put this code in a loop. This brings me to think that Jsoup is caching the webpage, but I need to disable this. Here's my code:
Document doc = null;
try {
doc = Jsoup.connect("http://www.reddit.com/r/nocontext/random").get();
Elements elements = doc.select("div.entry.unvoted p.title a.title");
for (Element link : elements)
System.out.println(link.text());
} catch (IOException e) {
e.printStackTrace();
}
Anyone have any insight on how to fix this problem?
It is most probably cached by the server. check the Rules in their API.
especially I quote this:
so make your request be every 30+ seconds and see if your problem is solved.
GET requests can be cached, where as POST requests can never be cached. Changing your connection request from get() to post() will avoid this.