X-Git-Url: https://git.phdru.name/?p=dotfiles.git;a=blobdiff_plain;f=bin%2Fget_html_encoding.py;h=381be9c10b19ea8fcbe78b05bc1f311ee28d1390;hp=4ffb44998588cfc87549c99c295eb103d8701725;hb=HEAD;hpb=f0344023aa21ede3b47d77559af54b97c37f328b diff --git a/bin/get_html_encoding.py b/bin/get_html_encoding.py index 4ffb449..381be9c 100755 --- a/bin/get_html_encoding.py +++ b/bin/get_html_encoding.py @@ -1,18 +1,13 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 - -from HTMLParser import HTMLParseError from m_lib.net.www.html import HTMLParser as _HTMLParser - class HTMLHeadDone(Exception): pass - class HTMLParser(_HTMLParser): def end_head(self): raise HTMLHeadDone() - def do_meta(self, attrs): http_equiv = "" content = "" @@ -41,14 +36,14 @@ def parse_html(filename): for line in infile: try: parser.feed(line) - except (HTMLParseError, HTMLHeadDone): + except HTMLHeadDone: break infile.close() try: parser.close() - except (HTMLParseError, HTMLHeadDone): + except HTMLHeadDone: pass if hasattr(parser, "charset"):