forked from Anri/cal8tor
get schedules of the timetable
This commit is contained in:
parent
b9c7a79afc
commit
aae662de56
2 changed files with 27 additions and 3 deletions
14
src/main.rs
14
src/main.rs
|
@ -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
16
src/models.rs
Normal 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,
|
||||
}
|
Loading…
Reference in a new issue