from bs4 import BeautifulSoup


def extract_html_links(text):
    """
    Grab any GOV.UK domain-specific links from page text.
    :param text: Text within a details sub-section, refer to filtered for keys.
    :return: list of links
    """
    links = []
    try:
        soup = BeautifulSoup(text, "html5lib")
        links = [link.get('href') for link in soup.findAll('a', href=True)]
    except Exception:
        print("error")
    return [l.replace("https://www.gov.uk/", "/") for l in links
            if l.startswith("/") or l.startswith("https://www.gov.uk/")]