CkPython
CkPython
Convert HTML to Plain Text
Demonstrates how to convert HTML to plain text.Chilkat CkPython Downloads
import sys
import chilkat
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
h2t = chilkat.CkHtmlToText()
html = h2t.readFileToString("c:/temp/test.html","utf-8")
if (h2t.get_LastMethodSuccess() == False):
print(h2t.lastErrorText())
sys.exit()
plainText = h2t.toText(html)
if (h2t.get_LastMethodSuccess() == False):
print(h2t.lastErrorText())
sys.exit()
print(plainText)