title: Convert Wikipedia/MediaWiki's code into HTML using python
body: <p>I am trying to grab content from Wikipedia and use the HTML of the article. Ideally I would also like to be able to alter the content (eg, hide certain infoboxes etc).</p>
  
  <p>I am able to grab page content using <a href="https://github.com/mwclient/mwclient" rel="nofollow">mwclient</a>:</p>
  
  <pre><code>&gt;&gt;&gt; import mwclient
  &gt;&gt;&gt; site = mwclient.Site('en.wikipedia.org')
  &gt;&gt;&gt; page = site.Pages['Samuel_Pepys']
  &gt;&gt;&gt; print page.text()
  {{Redirect|Pepys}}
  {{EngvarB|date=January 2014}}
  {{Infobox person
  ...
  </code></pre>
  
  <p>But I can't see a relatively simple, lightweight way to translate this wikicode into HTML using python.</p>
  
  <ul>
  <li><p><a href="http://johnmacfarlane.net/pandoc/" rel="nofollow">Pandoc</a> is too much for my needs.</p></li>
  <li><p>I could just scrape the original page using <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">Beautiful Soup</a> but that doesn't seem like a particularly elegant solution.</p></li>
  <li><p><a href="https://github.com/earwig/mwparserfromhell" rel="nofollow">mwparserfromhell</a> might help in the process, but I can't quite tell from the documentation if it gives me anything I need and don't already have.</p></li>
  <li><p>I can't see an obvious solution on the <a href="https://www.mediawiki.org/wiki/Alternative_parsers" rel="nofollow">Alternative Parsers</a> page.</p></li>
  </ul>
  
  <p>What have I missed?</p>
  
  <p><strong>UPDATE:</strong> <a href="http://www.gyford.com/phil/writing/2015/03/25/wikipedia-parsing.php" rel="nofollow">I wrote up what I ended up doing, following the discussion below</a>.</p>