capturing stdout from lynx..

Discussion in 'Python' started by sergio@village-buzz.com, Mar 11, 2006.

  1. Guest

    i have a huge database that contains large amounts of html that i need
    to translate to ascii..

    i have tried using html2text.py:

    http://www.aaronsw.com/2002/html2text/

    but i could not figure out how to import it and use it as a library
    without getting errors everywhere..

    so i decided to try using lynx with the -dump switch..

    it works great from the command line, but i am having trouble capturing
    the output into a python variable..

    the only way i have figured out how to do it is:

    s = subprocess(args='/sw/bin/lynx',stdout=subprocess.PIPE)

    but i can't figure out how to send it the "-dump" or the
    <filename.html> and retrieve the ouput..

    any help would be appreciated..
     
    , Mar 11, 2006
    #1
    1. Advertising

  2. Enigma Curry Guest

    Does this do what you want?

    import os
    filename = "test.html"
    cmd = os.popen("lynx -dump %s" % filename)
    output = cmd.read()
    cmd.close()
    print output
     
    Enigma Curry, Mar 11, 2006
    #2
    1. Advertising

  3. Guest

    perfect!

    that worked great!

    thank you!
     
    , Mar 13, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Dorward

    Re: Lynx

    David Dorward, Jun 27, 2003, in forum: HTML
    Replies:
    0
    Views:
    966
    David Dorward
    Jun 27, 2003
  2. Nicolai P. Zwar

    What's up with Lynx Browser Org?

    Nicolai P. Zwar, Jul 4, 2003, in forum: HTML
    Replies:
    8
    Views:
    855
    Thomas Dickey
    Jul 13, 2003
  3. Nico Schuyt

    Lynx for Win XP

    Nico Schuyt, Nov 21, 2003, in forum: HTML
    Replies:
    29
    Views:
    5,904
    Whitecrest
    Nov 25, 2003
  4. Replies:
    7
    Views:
    4,042
    Chuck Dillon
    Nov 22, 2004
  5. jl
    Replies:
    10
    Views:
    1,004
    cluedweasel
    Jun 29, 2005
Loading...

Share This Page