[Tutor] Redirecting output from the HTMLParser to a file
Quniceleaf Listservs
listservb@quinceleaf.com
Sun, 16 Dec 2001 01:40:20 -0500
I'm trying to filter an HTML file through the HTMLParser, and have been
experiencing trouble with what I'm attempting.
I'm reading in an HTML file, then passing it to a combination of
writer/formatter/HTMLparser. The various steps are omitted, as I've merely
used standard scripts from various Python books.
# print html body as plain text
p = htmllib.HTMLParser(f)
p.feed(workdata)
p.close()
It filters the HTML text (workdata) beautifully to the Interactive Window,
but I cannot get it to feed its output into a string or file, which is the
whole point of the exercise.
If I try to redirect the output to an open file via a write() command, I get
the error:
TypeError: argument 1 must be string or read-only character buffer, not
None
Does anyone have any advice? Does anyone know where I can find more detailed
information on the HTMLParser? The basic online documentation doesn't seem
to explain it in as much detail as I seem to need.