Beispiel #1
0
    def handle_starttag(self, tag, attrs):
        """Overidden - Parse links and convert them.

        <a> and <img> tags are looked for links."""
        # Special case 1: links
        if tag == 'a':
            for index, attr in enumerate(attrs):
                if attr[0] == 'href':
                    attrs[index] = attr[0], self.__fix_link__(attr[1])
                    break
        # Special case 2: images
        elif tag == 'img':
            for index, attr in enumerate(attrs):
                if attr[0] == 'src':
                    attrs[index] = attr[0], self.__fix_link__(attr[1])
                    break

        MyParser.handle_starttag(self, tag, attrs)
Beispiel #2
0
    def handle_starttag(self, tag, attrs):
        """Overidden - Parse links and convert them.

        <a> and <img> tags are looked for links."""
        # Special case 1: links
        if tag == 'a':
            for index, attr in enumerate(attrs):
                if attr[0] == 'href':
                    attrs[index] = attr[0], self.__fix_link__(attr[1])
                    break
        # Special case 2: images
        elif tag == 'img':
            for index, attr in enumerate(attrs):
                if attr[0] == 'src':
                    attrs[index] = attr[0], self.__fix_link__(attr[1])
                    break

        MyParser.handle_starttag(self, tag, attrs)