fork download
  1. import java.util.*;
  2. import java.util.stream.Collectors;
  3.  
  4. import com.google.common.collect.HashBasedTable;
  5. import com.google.common.collect.Table;
  6. import org.jsoup.Jsoup;
  7. import org.jsoup.nodes.Document;
  8. import org.jsoup.nodes.Element;
  9. import org.jsoup.select.Elements;
  10.  
  11.  
  12. public class ScheduleParser {
  13. public static void main(String[] args) throws Exception {
  14. final Table<String, String, String> table = HashBasedTable.create();
  15.  
  16. final Document doc = Jsoup.connect("http://localhost/index.html").userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
  17. .get();
  18. final Elements rows = doc.select("table tr");
  19. for (int r = 0; r < rows.size(); r++) {
  20. final List<Element> columns = rows.get(r).children().stream().filter(e -> e.tagName().equals("td") && !e.attr("colspan").equals("5")).collect(Collectors.toList());
  21. for (int c = 0; c < columns.size(); c++)
  22. table.put(Integer.toString(r) + " ", Integer.toString(c) + " ", columns.get(c).text());
  23. }
  24.  
  25. for (Table.Cell<String, String, String> cell : table.cellSet()) {
  26. System.out.println(cell.getRowKey() + " " + cell.getColumnKey() + " " + cell.getValue());
  27. }
  28. }
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:20: error: illegal start of expression
            final List<Element> columns = rows.get(r).children().stream().filter(e -> e.tagName().equals("td") && !e.attr("colspan").equals("5")).collect(Collectors.toList());
                                                                                    ^
1 error
stdout
Standard output is empty