So I'm building an app that displays an imageboard from a website I go to in a more user-friendly interface. There's a lot of problems with it at the moment, but the biggest one right now is fetching the images to display them.
The way I have it right now, the images are displayed in a GridView of size 12, mirroring the number of images on each page of the imageboard. I'm using Jsoup to scrape the page for the thumbnail image URLs to display in the GridView, as well as getting the URLs for the full size images to display when a user clicks on the thumbnail.
The problem right now is that it takes anywhere from 8-12 seconds on average for Jsoup to get the HTML page to scrape. This I find unacceptable and I was wondering if there was any way to make this faster or if this is going to be an inherent bottleneck that I can't do anything about.
Here's the code I'm using to fetch the page to scrape:
try {
Document doc = Jsoup.connect(url).get();
Elements links = doc.select("img[src*=/alt2/]");
for (Element link : links) {
thumbURL = link.attr("src");
linkURL = thumbURL.replace("/alt2/", "/").replace("s.jpg", ".jpg");
imgSrc.add(new Pair<String, String>(thumbURL, linkURL));
}
}
catch {
e.printStackTrace();
}