title: Extracting Text / Parse Text with html.parser (Python)
body: <p>I want to extract text from a html file, specifically from the <code>&lt;p&gt;</code> and <code>&lt;h1&gt;</code> Tag.
  I did see the code from the python doc regarding this topic:
  from html.parser import HTMLParser</p>
  <pre><code>class MyHTMLParser(HTMLParser):
      def handle_starttag(self, tag, attrs):
          print(&quot;Encountered a start tag:&quot;, tag)
  
      def handle_endtag(self, tag):
          print(&quot;Encountered an end tag :&quot;, tag)
  
      def handle_data(self, data):
          print(&quot;Encountered some data  :&quot;, data)
  
  parser = MyHTMLParser()
  parser.feed('&lt;html&gt;&lt;head&gt;&lt;title&gt;Test&lt;/title&gt;&lt;/head&gt;'
              '&lt;body&gt;&lt;h1&gt;Parse me!&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;')
  </code></pre>
  <p>But I'm not sure how to go from here, in order to extract only texts within certain tags (<p> and . Any hint and advice in the right direction is welcomed! (I do not want to use beautiful soup or any external libraries)</p>