title: Get the html under a tag using htmlparser python
body: <p>I want to get whole html under a tag and using HTMLParser. I am able to currently get the data between the tags and following is my code</p>
  
  <pre><code>class LinksParser(HTMLParser):
    def __init__(self):
      HTMLParser.__init__(self)
      self.recording = 0
      self.data = ''
  
    def handle_starttag(self, tag, attributes):
      if tag != 'span':
        return
      if self.recording:
        self.recording += 1
        return
      for name, value in attributes:
        if name == 'itemprop' and value == 'description':
          break
      else:
        return
      self.recording = 1
  
    def handle_endtag(self, tag):
      if tag == 'span' and self.recording:
        self.recording -= 1
  
    def handle_data(self, data):
      if self.recording:
        self.data += data
  </code></pre>
  
  <p>I also want the html tags inside the input for example</p>
  
  <pre><code>&lt;span itemprop="description"&gt;
  &lt;h1&gt;My First Heading&lt;/h1&gt;
  &lt;p&gt;My first &lt;br/&gt;&lt;br/&gt;paragraph.&lt;/p&gt;
  &lt;/span&gt;
  </code></pre>
  
  <p>when provided as input would only give me the data with out tags. Is there any method with which I can get whole html between the tags?</p>