Example #1
0
    def handle_starttag(self, tag, attrs):
        if tag == "pre":
            self.nofill = True
        if tag == "style":
            self._inter_css = True
        elif tag == "link":
            #TODO: do something -> download,open,load,parse css
            self._link_tag(attrs)

        elif tag == "img":
            #TODO: download from internet, change address
            if self._handle_img(attrs):
                Ent = HTMLEntity(tag, attrs)
                self._parse_css(Ent)
                self._opened_tags[-1].append(Ent) #add child
        else:
            Ent = HTMLEntity(tag, attrs)
            self._parse_css(Ent)
            for name, value in attrs:
                if name == "style":
                    Ent.add_css(value)


            if self._should_close_tag(tag):
                self._close_tag(tag)
            self._opened_tags[-1].append(Ent) #add child

            if not tag in ("br", "meta", "hr"):
                self._opened_tags.append(Ent) #add open tag
Example #2
0
 def handle_startendtag(self, tag, attrs):
     Ent = None
     if tag == "img":
         if self._handle_img(attrs):
             Ent = HTMLEntity(tag, attrs)
             self._parse_css(Ent)
     elif tag == "link":
         self._link_tag(attrs)
         return
     else:
         Ent = HTMLEntity(tag, attrs)
         for name, value in attrs:
             if name == "style":
                 Ent.add_css(value)
     if Ent:
         self._opened_tags[-1].append(Ent) #add child