get schedules of the timetable

This commit is contained in:
Mylloon 2022-08-12 21:20:39 +02:00
parent b9c7a79afc
commit aae662de56
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 27 additions and 3 deletions

View file

@ -1,5 +1,7 @@
use scraper::{Html, Selector};
mod models;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
//let url = "https://informatique.up8.edu/licence-iv/edt/l3.html";
@ -12,10 +14,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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(())
}

16
src/models.rs Normal file
View file

@ -0,0 +1,16 @@
pub struct Course {
/// Professor's name
pub professor: String,
/// List of rooms where the course takes place
pub room: Box<String>,
/// 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,
}