HTML -> text/plain "clever" formatting
Karl Scalet
news at yebu.de
Tue Oct 7 04:28:12 EDT 2003
Karl Scalet wrote:
> Gilles Lenfant wrote:
>
>>
>> Thanks Karl, I found what you're talking about
>>
>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52297
>>
>> Need to rework that TtyFormatter in depth to mimic lynx :o)
>>
>> Cheers
>>
>
> Hi Gilles
>
> actually I was talking about a different even similar example.
> But could not find it either in the online version. So maybe
> this is available only in the printed version, sorry.
> But if your recipe is good enough , why bother :-)
>
> Karl
>
finally found the online version under:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/67083
but this version deviates from the paper version in exactely
not having the code you're interessted in, so I'll add it here,
hopefully no one's complaining about this few lines:
import htmllib, formatter, cStringIO
textout = cStringIO.StringIO()
formtext = formatter.AbstractFormatter(formatter.DumbWriter(textout))
parser = htmllib.HTMLParser(formtext)
parser.feed(html)
parser.close()
text = textout.getvalue()
(not tested)
Karl
More information about the Python-list
mailing list