code: def _determine_base_url(document, page_url):
      
      for base in document.findall(".//base"):
          href = base.get("href")
          if href is not None:
              return href
      return page_url
docs: 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.