Solved this question as follows:
import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Test { private static List<String> silpoPages = Arrays.asList("http://silpo.ua/ua/actions/priceoftheweek/?PAGEN_1=1&", "http://silpo.ua/ua/actions/priceoftheweek/?PAGEN_1=2&", "http://silpo.ua/ua/actions/priceoftheweek/?PAGEN_1=3&"); public static void main(String[] args) { for (String silpoPage : silpoPages) { Document doc; Elements el; ArrayList<Element> list = new ArrayList<Element>(); try { doc = Jsoup.connect(silpoPage) .userAgent("Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36") .timeout(0) .get(); el = doc.getElementsByClass("photo"); String name; double newPrice, oldPrice; for (Element element : el) { name = element.select("h3").text(); newPrice = Double.parseDouble(element.select("div.price_2014_new").text()) / 100; if (!element.select("div.price_2014_old").text().equals("")){ oldPrice = Double.parseDouble(element.select("div.price_2014_old").text()) / 100; }else { oldPrice = 0; } System.out.println(name + " " + newPrice + "грн, " + oldPrice + "грн"); } } catch (IOException e) { e.printStackTrace(); System.out.println("Cannot open the site!"); } } } }
Perhaps not elegant and the formatting of prices should be corrected, but maybe someone will fit;)