From 894b16a7ef23fd7345bbd4fdcc13fceb7a64b412 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sun, 10 Apr 2016 12:39:51 +0530 Subject: [PATCH] Implement function error() for HTMLParser 1. Handle EXCEPTION [getTitleData]: (NotImplementedError) subclasses of ParserBase must override error() URL: http://www.mycplus.com/featured-articles/top-ten-c-language-resources/ 2. Add a debug log to show if server supports gzip --- buku | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/buku b/buku index 82200d3..45e8b66 100755 --- a/buku +++ b/buku @@ -103,6 +103,9 @@ class BMHTMLParser(HTMLParser.HTMLParser): if self.lasttag == "title" and self.inTitle == True: self.data += data + def error(self, message): + pass + def getDataPath(): @@ -240,6 +243,8 @@ def getTitleData(resp): charset = resp.headers.get_content_charset() if resp.headers.get('Content-Encoding') == 'gzip': + if debug: + print("gzip response") data = gzip.GzipFile(fileobj=io.BytesIO(resp.read())).read() else: data = resp.read()