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. Advertisements

  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. Advertisements

  3. Guest

    perfect!

    that worked great!

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

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. Moosebumps

    Capturing stdout incrementally

    Moosebumps, Apr 3, 2004, in forum: Python
    Replies:
    5
    Views:
    696
    David Bolen
    Apr 7, 2004
  2. Luigi
    Replies:
    5
    Views:
    583
    Donn Cave
    Apr 3, 2006
  3. Fuzzyman
    Replies:
    3
    Views:
    800
    Gabriel Genellina
    Jan 7, 2007
  4. Falcolas
    Replies:
    1
    Views:
    312
    Thomas Jollans
    Jun 27, 2007
  5. Nigel Wade
    Replies:
    8
    Views:
    1,271
    Lawrence D'Oliveiro
    Mar 18, 2011
  6. Bjorn Nordbo

    capturing stdout from so library

    Bjorn Nordbo, Sep 5, 2004, in forum: Ruby
    Replies:
    0
    Views:
    209
    Bjorn Nordbo
    Sep 5, 2004
  7. Navya Amerineni

    capturing the stdout

    Navya Amerineni, Mar 20, 2006, in forum: Ruby
    Replies:
    2
    Views:
    249
    Mauricio Fernandez
    Mar 20, 2006
  8. Mark Slater

    capturing stdout during unit tests

    Mark Slater, Aug 8, 2007, in forum: Ruby
    Replies:
    4
    Views:
    335
    Mark Slater
    Aug 8, 2007
Loading...