mirror of
https://github.com/Garmelon/PFERD.git
synced 2026-04-12 15:35:05 +02:00
Ilias9: Fix invalid course id
Ilias 9 seems to enforce a new url scheme, which brakes a lot of things
This commit is contained in:
parent
63f25277b0
commit
9bc6ab7f93
2 changed files with 9 additions and 5 deletions
|
|
@ -267,7 +267,7 @@ instance's greatest bottleneck.
|
|||
# If we expect to find a root course, enforce it
|
||||
if current_parent is None and expected_course_id is not None:
|
||||
perma_link = IliasPage.get_soup_permalink(soup)
|
||||
if not perma_link or "crs_" not in perma_link:
|
||||
if not perma_link or "crs" not in perma_link:
|
||||
raise CrawlError("Invalid course id? Didn't find anything looking like a course")
|
||||
if str(expected_course_id) not in perma_link:
|
||||
raise CrawlError(f"Expected course id {expected_course_id} but got {perma_link}")
|
||||
|
|
|
|||
|
|
@ -1301,10 +1301,14 @@ class IliasPage:
|
|||
|
||||
@staticmethod
|
||||
def get_soup_permalink(soup: BeautifulSoup) -> Optional[str]:
|
||||
perma_link_element = cast(Tag, soup.select_one(".il-footer-permanent-url > a"))
|
||||
if not perma_link_element or not perma_link_element.get("href"):
|
||||
for script in soup.find_all("script", attrs={'src': cast(str, None)}):
|
||||
match = re.search(
|
||||
r"((?:https?:\\\/\\\/)?(?:[^.]+\.)?ilias\.studium\.kit\.edu(\\\/.*)?)\"",
|
||||
script.text
|
||||
)
|
||||
if match is not None:
|
||||
return match.group(1)
|
||||
return None
|
||||
return cast(Optional[str], perma_link_element.get("href"))
|
||||
|
||||
|
||||
def _unexpected_html_warning() -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue