From 27ee15ba2d18120a8172993656db5384d1fac8b4 Mon Sep 17 00:00:00 2001 From: edpibu Date: Sun, 20 Sep 2020 21:26:53 +0200 Subject: [PATCH] inCell and inTable --- parser.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/parser.py b/parser.py index de4bc91..fee8b61 100755 --- a/parser.py +++ b/parser.py @@ -31,6 +31,7 @@ class GoogleSheetsCalParser(HTMLParser): """ def __init__(self): self.inTable = False + self.inCell = False self.row = -1 self.column = -1 HTMLParser.__init__(self) @@ -42,11 +43,16 @@ class GoogleSheetsCalParser(HTMLParser): self.column = -1 elif tag == 'td': self.column += 1 + if not (self.row < 3 or (self.row - 2) % 11 < 2): + self.inCell = True elif tag == 'tbody': self.inTable = True def handle_endtag(self, tag): - ... + if tag == 'td': + self.inCell = False + elif tag == 'tbody': + self.inTable = False def handle_data(self, data): ...