Loading muffin/integration/wwwstura/haushalt.py +6 −5 Original line number Diff line number Diff line import requests import re from uuid import UUID from bs4 import BeautifulSoup from pathlib import Path from ..schwalbe.studienfachschaften import get_studienfachschaften def parse_common_budget_plan_element(element): def parse_common_budget_plan_element(element) -> tuple[str, dict[str, str]]: studienfachschaft_name = element.text.split("\n")[0].strip() plan_links = {a.text: a.attrs["href"] for a in element.find_all("a")} return studienfachschaft_name, plan_links def is_common_budget_plan_element(element): def is_common_budget_plan_element(element) -> bool: return len(re.findall(r"\n", element.text)) == 1 def get_budget_plan_links(): def get_budget_plan_links() -> dict[str, dict[str, str]]: page = requests.get("https://www.stura.uni-heidelberg.de/finanzen/haushalt/") soup = BeautifulSoup(page.text, "html.parser") Loading @@ -33,7 +34,7 @@ def get_budget_plan_links(): ) def get_budget_plan_links_by_studienfachschaft_uuid(): def get_budget_plan_links_by_studienfachschaft_uuid() -> dict[UUID, dict[str, str]]: studienfachschaften = get_studienfachschaften() budget_plan_links_by_studienfachschaft_name = get_budget_plan_links() Loading @@ -53,7 +54,7 @@ def get_budget_plan_links_by_studienfachschaft_uuid(): return result def download_all_budget_plans(): def download_all_budget_plans() -> None: links = get_budget_plan_links_by_studienfachschaft_uuid() base_dir = Path("instance/budget_plans") Loading Loading
muffin/integration/wwwstura/haushalt.py +6 −5 Original line number Diff line number Diff line import requests import re from uuid import UUID from bs4 import BeautifulSoup from pathlib import Path from ..schwalbe.studienfachschaften import get_studienfachschaften def parse_common_budget_plan_element(element): def parse_common_budget_plan_element(element) -> tuple[str, dict[str, str]]: studienfachschaft_name = element.text.split("\n")[0].strip() plan_links = {a.text: a.attrs["href"] for a in element.find_all("a")} return studienfachschaft_name, plan_links def is_common_budget_plan_element(element): def is_common_budget_plan_element(element) -> bool: return len(re.findall(r"\n", element.text)) == 1 def get_budget_plan_links(): def get_budget_plan_links() -> dict[str, dict[str, str]]: page = requests.get("https://www.stura.uni-heidelberg.de/finanzen/haushalt/") soup = BeautifulSoup(page.text, "html.parser") Loading @@ -33,7 +34,7 @@ def get_budget_plan_links(): ) def get_budget_plan_links_by_studienfachschaft_uuid(): def get_budget_plan_links_by_studienfachschaft_uuid() -> dict[UUID, dict[str, str]]: studienfachschaften = get_studienfachschaften() budget_plan_links_by_studienfachschaft_name = get_budget_plan_links() Loading @@ -53,7 +54,7 @@ def get_budget_plan_links_by_studienfachschaft_uuid(): return result def download_all_budget_plans(): def download_all_budget_plans() -> None: links = get_budget_plan_links_by_studienfachschaft_uuid() base_dir = Path("instance/budget_plans") Loading