thieumao

Kết quả số xố

Nov 22nd, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.24 KB | None | 0 0
  1. package com.mkyong;
  2.  
  3. import java.io.IOException;
  4. import org.jsoup.Jsoup;
  5. import org.jsoup.nodes.Document;
  6. import org.jsoup.nodes.Element;
  7. import org.jsoup.select.Elements;
  8.  
  9. public class testXoSo {
  10.  
  11.     public static void main(String[] args) {
  12.  
  13.         Document doc;
  14.         try {
  15.  
  16.             // need http protocol
  17.             doc = Jsoup.connect("http://ketquaxoso.24h.com.vn/").get();
  18.  
  19.             // get page title
  20. //            String title = doc.title();
  21. //            System.out.println("title : " + title);
  22.  
  23.             int i = 0;
  24.             // get all links
  25.             Elements links = doc.select("td[class]");
  26.             for (Element link : links) {
  27.  
  28.                 // get the value from href attribute
  29.                 if (link.attr("class").equals("number_kq")) {
  30. //                    System.out.println("\nlink : " + link.attr("class"));
  31.                     switch (i){
  32.                         case 0:
  33.                             System.out.println("Giải đặc biệt: " + link.text());
  34.                             break;
  35.                         case 1:
  36.                             System.out.println("Giải nhất: " + link.text());
  37.                             break;
  38.                         case 2:
  39.                             System.out.println("Giải nhì: " + link.text());
  40.                             break;
  41.                         case 3:
  42.                             System.out.println("Giải ba: " + link.text());
  43.                             break;
  44.                         case 4:
  45.                             System.out.println("Giải tư: " + link.text());
  46.                             break;
  47.                         case 5:
  48.                             System.out.println("Giải năm: " + link.text());
  49.                             break;
  50.                         case 6:
  51.                             System.out.println("Giải sáu: " + link.text());
  52.                             break;
  53.                         case 7:
  54.                             System.out.println("Giải bảy: " + link.text());
  55.                             break;
  56.                     }
  57.                     i++;
  58.                 }
  59.  
  60.             }
  61.  
  62.         } catch (IOException e) {
  63.             e.printStackTrace();
  64.         }
  65.  
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment