Source code for proboards_scraper.scraper.utils

import re
from typing import Tuple

def int_(num: str) -> int:
    Take an integer in the form of a string, remove any commas from it,
    then return it as an ``int``.

        num: A string containing only numeric characters or commas.

        An integer version of the string.
    return int(num.replace(",", ""))

[docs]def split_url(url: str) -> Tuple[str, str]: """ Given a forum page URL like, e.g., ``, return the base URL (``) and resource path component (`board/3/board-name`). Site/page URLs take the following forms: * Homepage: * Board: * Thread: * Users: * User: Args: url: URL to a forum page. Returns: :data:`(base_url, path)` The base URL and resource path URL component (or ``None`` if ``url`` is just the base/homepage URL). """ url = url.rstrip("/") expr = r"(^.*\.com)(/.*)?$" match = re.match(expr, url) base_url, path = match.groups() return base_url, path