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);
- // 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"));
- System.out.println("text : " + link.text());
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment