import re


def update_page_number(url, page=1):
    # type: (str, int) -> str
    """Updates or appends the 'page' parameter for a URL"""
    pattern = r"page=(\d+)"
    return re.sub(pattern, "page={}".format(page), url) \
        if re.search(pattern, url) \
        else "{}&page={}".format(url, page)