Skip to content

route()

Class: PortalRouter
File: jobs_austria_details_scraping.py ยท line 51

Group URLs by their portal. Unrecognized portals are grouped under UNKNOWN instead of being dropped. Returns a dict of {portal: [url, ...]}.

Signature

Parameters urls
Returns dict
Async No
Visibility Public

Implementation

def route(self, urls: list[str]) -> dict[str, list[str]]:
    """
    Group URLs by their portal.
    Unrecognized portals are grouped under UNKNOWN instead of being dropped.
    Returns a dict of  {portal: [url, ...]}.
    """
    groups: dict[str, list[str]] = {}
    for url in urls:
        portal = self._extract_portal(url)
        key = portal if portal in self._PORTAL_INPUTS else self.UNKNOWN
        groups.setdefault(key, []).append(url)
    return groups