(link, root_url)
return link
Normalizes links extracted from the DOM by making them all absolute, so
        we can request them, for example, turns a "/images" link extracted from https://imgur.com
        to "https://imgur.com/images"
        :param link: link found in the DOM
        :param root_url: the URL the DOM was loaded from
        :return: absolute link
Normalizes links extracted from the DOM by making them all absolute, so
        we can request them, for example, turns a "/images" link extracted from https://imgur.com
        to "https://imgur.com/images"
        :param link: link found in the DOM
        :param root_url: the URL the DOM was loaded from
        :return: absolute link
Normalizes links extracted from the DOM by making them all absolute so we can request them for example turns a / images link extracted from https : // imgur . com to https : // imgur . com / images : param link : link found in the DOM : param root_url : the URL the DOM was loaded from : return : absolute link
def _normalize_link(link, root_url):
        """
        Normalizes links extracted from the DOM by making them all absolute, so
        we can request them, for example, turns a "/images" link extracted from https://imgur.com
        to "https://imgur.com/images"
        :param link: link found in the DOM
        :param root_url: the URL the DOM was loaded from
        :return: absolute link
        """
        try:
            parsed_url = urlparse(link)
        except ValueError:
            # urlparse can get confused about urls with the ']'
            # character and thinks it must be a malformed IPv6 URL
            return None
        parsed_root_url = urlparse(root_url)

        # '//' means keep the current protocol used to access this URL
        if link.startswith("//"):
            return "{}://{}{}".format(parsed_root_url.scheme, parsed_url.netloc, parsed_url.path)

        # possibly a relative path
        if not parsed_url.scheme:
            return urljoin(root_url, link)

        return link
def _normalize_link ( link , root_url ) : try : parsed_url = urlparse ( link ) except ValueError : # urlparse can get confused about urls with the ']' # character and thinks it must be a malformed IPv6 URL return None parsed_root_url = urlparse ( root_url ) # '//' means keep the current protocol used to access this URL if link . startswith ( "//" ) : return "{}://{}{}" . format ( parsed_root_url . scheme , parsed_url . netloc , parsed_url . path ) # possibly a relative path if not parsed_url . scheme : return urljoin ( root_url , link ) return link