From 5fc7d9209c8b9c1c09ba44c8172bd6c2eca98be9 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 28 Sep 2023 00:23:51 +0200 Subject: [PATCH] Fix some bugs --- src/info.rs | 4 ++-- src/timetable.rs | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/info.rs b/src/info.rs index e295501..c6586cd 100644 --- a/src/info.rs +++ b/src/info.rs @@ -12,10 +12,10 @@ pub async fn info( user_agent: &str, ) -> HashMap, i64)>> { let semester = get_semester(semester_opt); - let year = get_year(year_opt, semester); - let document = get_webpage(level, semester, &year, user_agent) + // Fetch the timetable of the FIRST semester + let document = get_webpage(level, 1, &year, user_agent) .await .expect("Can't reach info website."); diff --git a/src/timetable.rs b/src/timetable.rs index bc53162..8adc0f9 100644 --- a/src/timetable.rs +++ b/src/timetable.rs @@ -89,11 +89,13 @@ pub async fn timetable( .name("name") .unwrap() .as_str().to_owned(), - professor: match i.select(&sel_small).last().unwrap().inner_html() { - i if i.starts_with(" None, - i => Some(i), - }, - room: Regex::new(r"(|
.*?
.*?)
(?P.*?)
") + professor: if let Some(raw_prof) = i.select(&sel_small).last() { + match raw_prof.inner_html() { + i if i.starts_with(" None, + i => Some(i), + } + } else { None }, + room: Regex::new(r"(|
.*?
.*?)?
(?P.*?)
") .unwrap() .captures(&binding) .unwrap().name("location")