I want to print html for a document, but I want it to be formatted as it will be viewed on a web page.
I have the following code:
from BeautifulSoup import BeautifulSoup, NavigableString
html = """
<B>THIS IS A TABLE</B>
</div>
<center>
<table width="100%" align="center" cellspacing="0" cellpadding="0" border="0" style="font-size: 10pt; margin-top: 6pt; ">
<tr style="font-size: 7pt;">
<td colspan="2" align="left" nowrap><B>THIS IS A HEADER1</B></td>
<td> </td>
<td colspan="3" align="center" nowrap><B> THIS IS A HEADER2</B></td>
<td> </td>
<td colspan="3" align="center" nowrap><B> THIS IS A HEADER3</B></td>
<td> </td>
<td colspan="3" align="center" nowrap><B> THIS IS A HEADER4</B></td>
<td> </td>
</tr>
</table>
"""
soup = BeautifulSoup(''.join(html))
tmp.open('tmp.txt','w')
tmp.write(soup)
tmp.close()
But it prints html with tags. Any way to do this in python?
source
share