From 8ab462fb87e8bdfac8bfd6821645dd9f4617e898 Mon Sep 17 00:00:00 2001 From: I-Al-Istannen Date: Fri, 4 Jun 2021 19:23:33 +0200 Subject: [PATCH] Use the exercise label instead of the button name as path --- CHANGELOG.md | 2 ++ PFERD/crawl/ilias/kit_ilias_html.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32cbe77..171a61c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ ambiguous situations. ### Changed - Use `/` instead of `\` as path separator for (regex) rules on Windows +- Use the label to the left for exercises instead of the button name to + determine the folder name ## 3.0.1 - 2021-06-01 diff --git a/PFERD/crawl/ilias/kit_ilias_html.py b/PFERD/crawl/ilias/kit_ilias_html.py index 64491f9..db9a303 100644 --- a/PFERD/crawl/ilias/kit_ilias_html.py +++ b/PFERD/crawl/ilias/kit_ilias_html.py @@ -293,7 +293,13 @@ class IliasPage: # Add each listing as a new for listing in file_listings: - file_name = _sanitize_path_name(listing.getText().strip()) + parent_container: Tag = listing.findParent( + "div", attrs={"class": lambda x: x and "form-group" in x} + ) + label_container: Tag = parent_container.find( + attrs={"class": lambda x: x and "control-label" in x} + ) + file_name = _sanitize_path_name(label_container.getText().strip()) url = self._abs_url_from_link(listing) log.explain(f"Found exercise detail {file_name!r} at {url}") results.append(IliasPageElement(