无法使用Jsoup显示表内容并在Netbeans中显示它

时间:2014-06-09 13:01:14

标签: java netbeans-7

这是我的代码

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Iterator;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class CollegeOfScience {
    private static Iterable<Elements> url;

    public static void main(String[] args)throws IOException, SQLException, InterruptedException {
        Document doc;
        //Load a Document from a URL
        //doc = Jsoup.connect("https://science.swansea.ac.uk/intranet/attendance/timetable/" ).get();
        //Load a Document from a File
        File input = new File("/temp/input.htm");
        doc = Jsoup.parse(input,"UTF-8","https://science.swansea.ac.uk/intranet/attendance/timetable/" );
        // System.out.println(doc);
        String title = doc.title();
        System.out.println(title);
        //System.out.println(doc);
        //Elements urls = doc.select("a");
        for(Element table : doc.select("table.timetable")) {  
            for (Element row : table.select("tr")) {
                Elements tds = row.select("td");
                if (tds.size() > 1) {
                    System.out.println(tds.get(0).text()+":"+tds.get(3).text());
                }
            }
        }
    }
}  

0 个答案:

没有答案