Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Map<String, List<Integer>> numeriEstratti = new HashMap<String, List<Integer>>();
- // NB: controllate di importare le classi giuste
- Document doc = Jsoup.connect("http://www.estrazionedellotto.it/").timeout(0).get();
- //.userAgent("Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22")
- //.timeout(30000).get();
- //System.out.println("doc"+doc);
- // prendo la tabella
- // (con .first() ottengo il primo elemento, in questo caso l'unico )
- Elements elements = doc.getElementsByAttributeValueContaining("class", "nomeRuota estratto");
- for(Element element : elements){
- Element parent = element.parent();
- String chiave = element.text();
- List<Integer> numeri = new ArrayList<Integer>();
- for(Element e : parent.children()){
- System.out.println(e.text());
- if(e.text().length() > 0) {
- try {
- Integer numero = Integer.parseInt(e.text());
- numeri.add(numero);
- }catch (NumberFormatException nfe){
- // TODO
- }
- }
- }
- numeriEstratti.put(chiave, numeri);
- }
- System.out.println(numeriEstratti);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement