From aae662de56304e2a3e1596f99a10a11d723db17b Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 12 Aug 2022 21:20:39 +0200 Subject: [PATCH] get schedules of the timetable --- src/main.rs | 14 +++++++++++--- src/models.rs | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/models.rs diff --git a/src/main.rs b/src/main.rs index 174d748..36a6f1b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,7 @@ use scraper::{Html, Selector}; +mod models; + #[tokio::main] async fn main() -> Result<(), Box> { //let url = "https://informatique.up8.edu/licence-iv/edt/l3.html"; @@ -12,10 +14,16 @@ async fn main() -> Result<(), Box> { let document = Html::parse_document(&html); // Find the timetable - let selector = Selector::parse("table").unwrap(); - let raw_timetable = document.select(&selector); + let selector_timetable = Selector::parse("table").unwrap(); + let raw_timetable = document.select(&selector_timetable).next().unwrap(); + + //println!("{}", &raw_timetable.inner_html()); + + // Find the slots available for the timetable + let selector_schedules = Selector::parse("tr").unwrap(); + let raw_schedules = raw_timetable.select(&selector_schedules).next().unwrap(); + println!("{}", &raw_schedules.inner_html()); - println!("{:#?}", raw_timetable); Ok(()) } diff --git a/src/models.rs b/src/models.rs new file mode 100644 index 0000000..d9a00bb --- /dev/null +++ b/src/models.rs @@ -0,0 +1,16 @@ +pub struct Course { + /// Professor's name + pub professor: String, + + /// List of rooms where the course takes place + pub room: Box, + + /// Time the course starts, as a number : + /// - 0 => first possible class of the day + /// - 1 => second possible class of the day + /// - etc. + pub start: i8, + + /// Number of time slots the course takes up in the timetable + pub size: i8, +}