From eb3086c448d558ca0a68da40b62b824b2018e0a3 Mon Sep 17 00:00:00 2001 From: bilal Date: Wed, 20 Apr 2022 16:00:13 +0300 Subject: [PATCH 1/2] Tried extracting table in another way --- TrySRS.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TrySRS.java b/TrySRS.java index 86a778f..58913a4 100644 --- a/TrySRS.java +++ b/TrySRS.java @@ -2,6 +2,7 @@ * @author bilal * gives the schedule of given url in boolean and byte format */ +import javax.lang.model.element.Element; import org.jsoup.*;import org.jsoup.nodes.*; public class TrySRS { @@ -29,7 +30,6 @@ public static void main(String[] args) { semester = "1"; } - Document doc = Jsoup.connect("https://stars.bilkent.edu.tr/syllabus/view/" + deptCode + "/" + numberCode +"/" + year + semester +"?section=" + section).get(); scheduleMaker( sourceParser(doc.toString())); sc.close(); From bba0032952ad8bca67a78b3f592292806a158cb7 Mon Sep 17 00:00:00 2001 From: bilal Date: Sun, 24 Apr 2022 22:08:24 +0300 Subject: [PATCH 2/2] Make year and semester default as 2021-2022 spring --- TrySRS.java | 484 ++-------------------------------------------------- 1 file changed, 14 insertions(+), 470 deletions(-) diff --git a/TrySRS.java b/TrySRS.java index 58913a4..784206a 100644 --- a/TrySRS.java +++ b/TrySRS.java @@ -19,16 +19,19 @@ public static void main(String[] args) { System.out.println("enter the section number:"); String section = sc.nextLine(); - System.out.println("enter the year:"); - String year = sc.nextLine(); + /*System.out.println("enter the year:"); + String year = sc.nextLine();*/ + String year = 2021; //by default, which we will use for 2021-2022 spring - System.out.println("spring or fall?:"); + /*System.out.println("spring or fall?:"); String semester = sc.nextLine().toLowerCase(); if (semester.equals("spring")) {semester = "2";} else { semester = "1"; - } + }*/ + String semester = 2; //by default, which we will use for 2021-2022 spring + Document doc = Jsoup.connect("https://stars.bilkent.edu.tr/syllabus/view/" + deptCode + "/" + numberCode +"/" + year + semester +"?section=" + section).get(); scheduleMaker( sourceParser(doc.toString())); @@ -41,469 +44,10 @@ public static void main(String[] args) { } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Looking at the source requires punishment. Do not look at it. Besides, you will regret it. - * @param source - * @return + * @param source is the html to parse + * @return the code in wanted String format */ public static String sourceParser(String source) { String toReturn = ""; @@ -511,10 +55,10 @@ public static String sourceParser(String source) { int end = 0; for (int i = 0; i < source.length() - 35; i++) { - if (source.substring(i,i+24).equals("Sun")) + if (source.substring(i,i+24).equals("Sun")) //find the place to parse start = i; - if (source.substring(i, 31+i).equals("")) + if (source.substring(i, 31+i).equals("
")) //find the place to parse end = i; } toReturn = source.substring(start, end); @@ -523,11 +67,11 @@ public static String sourceParser(String source) { return toReturn; } public static void scheduleMaker(String html) { - int saatSlotu = 0; - int xCoordinate = 0; + int saatSlotu = 0; //to track the hours + int xCoordinate = 0; //to track the days int[][] schedule = new int[14][7]; - //System.out.println(divTag); + //System.out.println(divTag); //was to check System.out.println("\t monday\ttuesday\t wednesday thursday friday saturday sunday"); for (int i = 0; i < html.length() - 16; i++) {