You are viewing a single comment's thread. Return to all comments →
from html.parser import HTMLParser K_NEW_LINE_SEPARATOR = '\n' class MyHTMLParser(HTMLParser): def handle_comment(self, data) -> None: comment_str = ">>> Single-line Comment" if K_NEW_LINE_SEPARATOR in data: comment_str = ">>> Multi-line Comment" print(comment_str, data, sep=K_NEW_LINE_SEPARATOR) def handle_data(self, data) -> None: if data != K_NEW_LINE_SEPARATOR: print(">>> Data", data, sep=K_NEW_LINE_SEPARATOR)
Seems like cookies are disabled on this browser, please enable them to open this website
HTML Parser - Part 2
You are viewing a single comment's thread. Return to all comments →