Python equivalent of "lynx -dump"?

lewst lewst at yahoo.com
Wed Mar 29 19:11:54 EST 2000


ben at co.and.co writes:

> > I'm looking for a functional equivalent of the "-dump" option to the
> > lynx web-browser in Python.  "-dump" dumps the formatted output of an
> > HTML document.
> 
> > Right now I have a python program that captures the output of a
> > webpage and prints it like so:
> 
> >         lynxcmd = "lynx -dump %s" %url
> >         data = os.popen(lynxcmd).read()
> >         print data
> 
> An all Python solution is a little bit more complicated:
> 
> import htmllib, formatter 
> 
> p = htmllib.HTMLParser(formatter.AbstractFormatter(formatter.DumbWriter()))
> f = open('test.html')
> p.feed(f.read())
> p.close()
> f.close()

Yes, but how can I store the output of "p.feed(f.read())" in a
variable such as `data' like I'm doing above with lynxcmd.  Your 
code writes everything out to the terminal.


__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com




More information about the Python-list mailing list