Fix some bugs
This commit is contained in:
parent
dc3a5c6d8e
commit
5fc7d9209c
2 changed files with 9 additions and 7 deletions
|
@ -12,10 +12,10 @@ pub async fn info(
|
||||||
user_agent: &str,
|
user_agent: &str,
|
||||||
) -> HashMap<usize, Vec<(DateTime<Utc>, i64)>> {
|
) -> HashMap<usize, Vec<(DateTime<Utc>, i64)>> {
|
||||||
let semester = get_semester(semester_opt);
|
let semester = get_semester(semester_opt);
|
||||||
|
|
||||||
let year = get_year(year_opt, semester);
|
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
|
.await
|
||||||
.expect("Can't reach info website.");
|
.expect("Can't reach info website.");
|
||||||
|
|
||||||
|
|
|
@ -89,11 +89,13 @@ pub async fn timetable(
|
||||||
.name("name")
|
.name("name")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_str().to_owned(),
|
.as_str().to_owned(),
|
||||||
professor: match i.select(&sel_small).last().unwrap().inner_html() {
|
professor: if let Some(raw_prof) = i.select(&sel_small).last() {
|
||||||
|
match raw_prof.inner_html() {
|
||||||
i if i.starts_with("<span") => None,
|
i if i.starts_with("<span") => None,
|
||||||
i => Some(i),
|
i => Some(i),
|
||||||
},
|
}
|
||||||
room: Regex::new(r"(<table.*<\/table>|<br>.*?<br>.*?)<br>(?P<location>.*?)<br>")
|
} else { None },
|
||||||
|
room: Regex::new(r"(<table.*<\/table>|<br>.*?<br>.*?)?<br>(?P<location>.*?)<br>")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.captures(&binding)
|
.captures(&binding)
|
||||||
.unwrap().name("location")
|
.unwrap().name("location")
|
||||||
|
|
Reference in a new issue