title: Converting html to text with Python
body: <p>I am trying to convert an html block to text using Python.</p>
  <p><strong>Input:</strong></p>
  <pre><code>&lt;div class=&quot;body&quot;&gt;&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa&lt;/p&gt;
  &lt;p&gt;Consectetuer adipiscing elit. &lt;a href=&quot;http://example.com/&quot; target=&quot;_blank&quot; class=&quot;source&quot;&gt;Some Link&lt;/a&gt; Aenean commodo ligula eget dolor. Aenean massa&lt;/p&gt;
  &lt;p&gt;Aenean massa.Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa&lt;/p&gt;
  &lt;p&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa&lt;/p&gt;
  &lt;p&gt;Consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa&lt;/p&gt;&lt;/div&gt;
  </code></pre>
  <p><strong>Desired output:</strong></p>
  <blockquote>
  <p><strong></strong></p> <p><strong></strong>Lorem
  ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo
  ligula eget dolor. Aenean massa</p> <p>Consectetuer adipiscing elit.
  Some
  Link Aenean commodo ligula eget dolor. Aenean massa</p> <p>Aenean
  massa.Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
  commodo ligula eget dolor. Aenean massa</p> <p>Lorem ipsum dolor sit
  amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.
  Aenean massa</p> <p>Consectetuer adipiscing elit. Aenean commodo
  ligula eget dolor. Aenean massa</p>
  </blockquote>
  <p>I tried the <code>html2text</code> module without much success:</p>
  <pre><code>#!/usr/bin/env python
  
  import urllib2
  import html2text
  from BeautifulSoup import BeautifulSoup
  
  soup = BeautifulSoup(urllib2.urlopen('http://example.com/page.html').read())
  
  txt = soup.find('div', {'class' : 'body'})
  
  print(html2text.html2text(txt))
  </code></pre>
  <p>The <code>txt</code> object produces the html block above. I'd like to convert it to text and print it on the screen.</p>