[Tutor] htmllib, formatter and results as a string

Scott Griffitts scott@griffitts.com
Wed, 03 Oct 2001 21:37:04 -0500


I'm trying to take a html file and format it in plain text (with some other
formatting thrown in - see below).  The code below gets me pretty close:

import htmllib, formatter

w = formatter.DumbWriter()
f = formatter.AbstractFormatter(w)

file = open('C://test//test.html')

p = htmllib.HTMLParser(f)
p.feed(file.read())
p.close()
file.close()

But I want to do some additional formatting.  The p.feed(file.read()) part
of the code is (to my newbie understanding) sending the result to stdout.  I
would like to catch it as a string so I can perform some further tweaking.
How do I do that?

Thanks,

Scott