+ raise RedirectException("html", "%s (%s sec)" % (url, timeout))
+
+ # Get favicon.ico
+ icon = parser.icon
+ if not icon:
+ icon = "/favicon.ico"
+ icon = urljoin("%s://%s%s" % (url_type, url_host, url_path), icon)
+ if self.log: self.log(" icon : %s" % icon)
+ try:
+ fname, headers = urllib.urlretrieve(icon)
+ except:
+ etype, emsg, tb = sys.exc_info()
+ if self.log: self.log(" no icon : %s %s" % (etype, emsg))
+ etype = None
+ emsg = None
+ tb = None
+ else:
+ content_type = headers["Content-Type"]
+ if content_type.startswith("image/"):
+ icon_file = open(fname, "rb")
+ icon = icon_file.read()
+ icon_file.close()
+ bookmark.icon = "data:%s;base64,%s" % (content_type, b64encode(icon))
+ else:
+ if self.log: self.log(" no icon : %s" % content_type)
+ os.remove(fname)
+