29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
|
|
from html.parser import HTMLParser
|
|
|
|
class DivStructurePrinter(HTMLParser):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.stack = []
|
|
|
|
def handle_starttag(self, tag, attrs):
|
|
if tag == 'div':
|
|
attr_dict = dict(attrs)
|
|
ident = attr_dict.get('id', '')
|
|
if ident in ['fileTabsContent', 'processed', 'repository', 'repoTabsContent', 'pills-backup']:
|
|
print(f"OPEN {ident:15} at line {self.getpos()[0]} (Stack depth: {len(self.stack)})")
|
|
self.stack.append(ident)
|
|
|
|
def handle_endtag(self, tag):
|
|
if tag == 'div':
|
|
if self.stack:
|
|
ident = self.stack.pop()
|
|
if ident in ['fileTabsContent', 'processed', 'repository', 'repoTabsContent', 'pills-backup']:
|
|
print(f"CLOSE {ident:15} at line {self.getpos()[0]} (Stack depth: {len(self.stack)})")
|
|
|
|
with open(r"d:\Code\iDRAC_Info\idrac_info\backend\templates\index.html", "r", encoding="utf-8") as f:
|
|
content = f.read()
|
|
|
|
parser = DivStructurePrinter()
|
|
parser.feed(content)
|