def _determine_base_url(document, page_url):
    "Determine the HTML document's base URL.\n\n    This looks for a ``<base>`` tag in the HTML document. If present, its href\n    attribute denotes the base URL of anchor tags in the document. If there is\n    no such tag (or if it does not have a valid href attribute), the HTML\n    file's URL is used as the base URL.\n\n    :param document: An HTML document representation. The current\n        implementation expects the result of ``html5lib.parse()``.\n    :param page_url: The URL of the HTML document.\n    "
    for base in document.findall('.//base'):
        href = base.get('href')
        if (href is not None):
            return href
    return page_url
Determine the HTML document's base URL.

This looks for a ``<base>`` tag in the HTML document. If present, its href
attribute denotes the base URL of anchor tags in the document. If there is
no such tag (or if it does not have a valid href attribute), the HTML
file's URL is used as the base URL.

:param document: An HTML document representation. The current
    implementation expects the result of ``html5lib.parse()``.
:param page_url: The URL of the HTML document.
def _determine_base_url(document, page_url):
    "Determine the HTML document's base URL.\n\n    This looks for a ``<base>`` tag in the HTML document. If present, its href\n    attribute denotes the base URL of anchor tags in the document. If there is\n    no such tag (or if it does not have a valid href attribute), the HTML\n    file's URL is used as the base URL.\n\n    :param document: An HTML document representation. The current\n        implementation expects the result of ``html5lib.parse()``.\n    :param page_url: The URL of the HTML document.\n    "
    for base in document.findall('.//base'):
        href = base.get('href')
        if (href is not None):
            return href
    return page_url