Using HTMLParser in Python 3.2

陌路散爱 提交于 2019-12-02 20:51:35

You're subclassing HTMLParser, but you aren't calling its __init__ method. You need to add one line to your __init__ method:

def __init__(self):
    super().__init__()
    self.reset()
    self.fed = []

Also, for Python 3, the import line is:

from html.parser import HTMLParser

With these changes, a simple example works. Don't change the class line, that's not related.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!