Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mkyong;
- import java.io.IOException;
- import org.jsoup.Jsoup;
- import org.jsoup.nodes.Document;
- import org.jsoup.nodes.Element;
- import org.jsoup.select.Elements;
- public class testXoSo {
- public static void main(String[] args) {
- Document doc;
- try {
- // need http protocol
- doc = Jsoup.connect("http://ketquaxoso.24h.com.vn/").get();
- // get page title
- // String title = doc.title();
- // System.out.println("title : " + title);
- int i = 0;
- // get all links
- Elements links = doc.select("td[class]");
- for (Element link : links) {
- // get the value from href attribute
- if (link.attr("class").equals("number_kq")) {
- // System.out.println("\nlink : " + link.attr("class"));
- switch (i){
- case 0:
- System.out.println("Giải đặc biệt: " + link.text());
- break;
- case 1:
- System.out.println("Giải nhất: " + link.text());
- break;
- case 2:
- System.out.println("Giải nhì: " + link.text());
- break;
- case 3:
- System.out.println("Giải ba: " + link.text());
- break;
- case 4:
- System.out.println("Giải tư: " + link.text());
- break;
- case 5:
- System.out.println("Giải năm: " + link.text());
- break;
- case 6:
- System.out.println("Giải sáu: " + link.text());
- break;
- case 7:
- System.out.println("Giải bảy: " + link.text());
- break;
- }
- i++;
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment