title: Using HTMLParser in Python 3.2
body: <p>I have been using HTML Parser to scrapping data from websites and stripping html coding whilst doing so. I'm aware of various modules such as Beautiful Soup, but decided to go down the path of not depending on "outside" modules. There is a code code supplied by Eloff: <a href="https://stackoverflow.com/a/925630/3416774">Strip HTML from strings in Python</a></p>
  
  <pre><code>from HTMLParser import HTMLParser
  
  class MLStripper(HTMLParser):
      def __init__(self):
          self.reset()
          self.fed = []
      def handle_data(self, d):
          self.fed.append(d)
      def get_data(self):
          return ''.join(self.fed)
  
  def strip_tags(html):
      s = MLStripper()
      s.feed(html)
      return s.get_data()
  </code></pre>
  
  <p>It works in Python 3.1. However, I recently upgraded to Python 3.2.x and have found I get errors regarding the HTML Parser code as written above.</p>
  
  <p>My first error points to the line:</p>
  
  <pre><code>s.feed(html)
  </code></pre>
  
  <p>... and the error says ...</p>
  
  <pre><code>AttributeError: 'MLStripper' object has no attribute 'strict'
  </code></pre>
  
  <p>So, after a bit of research, I add "strict=True" to the top line, making it...</p>
  
  <pre><code>class MLStripper(HTMLParser, strict=True)
  </code></pre>
  
  <p>However, I get the new error of:</p>
  
  <pre><code>TypeError: type() takes 1 or 3 arguments
  </code></pre>
  
  <p>To see what would happen, I removed the "self" argument and left in the "strict=True"... which gave up the error:</p>
  
  <pre><code>NameError: global name 'self' is not defined
  </code></pre>
  
  <p>... and I got the "I'm guessing on guesses" feeling.</p>
  
  <p>I have no idea what the third argument in the <code>class MLStripper(HTMLParser)</code> line would be, after <code>self</code> and <code>strict=True</code>; research didn't toss any enlightenment.</p>