Sample code for 30+ languages & platforms
Chilkat2-Python

Convert HTML to Plain Text

Demonstrates how to convert HTML to plain text.

Chilkat Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

h2t = chilkat2.HtmlToText()

html = h2t.ReadFileToString("c:/temp/test.html","utf-8")
if (h2t.LastMethodSuccess == False):
    print(h2t.LastErrorText)
    sys.exit()

plainText = h2t.ToText(html)
if (h2t.LastMethodSuccess == False):
    print(h2t.LastErrorText)
    sys.exit()

print(plainText)