- self.tags.append(u'br')
- self.handle_curdata() # just handle the data, don't do anything else
- self.tags.pop()
+ self.handle_br()
+ elif tag.lower() == u'img':
+ self.handle_image(attrs)
+ return
+
+ def handle_br(self):
+ self.handle_curdata()
+ self.opentags.append(u'br')
+ self.handle_curdata()
+ self.opentags.pop()
+
+ def handle_image(self, attrs):
+ alt = u''
+ url = u''
+ for attr in attrs:
+ if attr[0] == 'alt':
+ if isinstance(attr[1], str):
+ alt = u'%s' %(attr[1].decode("utf-8"))
+ else:
+ alt = attr[1]
+ elif attr[0] == 'src':
+ if isinstance(attr[1], str):
+ url = u'%s' %(attr[1].decode("utf-8"))
+ else:
+ url = attr[1]
+ if url:
+ if alt:
+ if self.images.has_key(alt):
+ if self.images[alt]["url"] == url:
+ self.curdata = self.curdata \
+ + u'|%s|' %(alt,)
+ else:
+ while self.images.has_key(alt):
+ alt = alt + "_"
+ self.images[alt] = {"url": url}
+ self.curdata = self.curdata \
+ + u'|%s|' %(alt,)
+ else:
+ self.images[alt] = {"url": url}
+ self.curdata = self.curdata \
+ + u'|%s|' %(alt,)
+ else:
+ if self.images.has_key(url):
+ self.curdata = self.curdata \
+ + u'|%s|' %(url,)
+ else:
+ self.images[url] = {}
+ self.images[url]["url"] =url
+ self.curdata = self.curdata \
+ + u'|%s|' %(url,)