Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3698436
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:58:52+00:00 2026-05-19T04:58:52+00:00

I am sending an HTML text from PHP to Python via STDIN. My objctive

  • 0

I am sending an HTML text from PHP to Python via STDIN. My objctive is to use Aaron Swartz’s script “html2text.py” and to print the result to PHP via STDOUT.

Camarade Jan gave me the word and put me in the right direction. Here’s my test:

PHP code:

$t='<p><b>Hello</b><i>world!</i></p>';
$scaped=preg_quote($t,"/")."\n";//\<p\>\<b\>Hello\<\/b\>\<i\>world\!\<\/i\>\<\/p\>
exec('python hi.py '.$scaped,$r);
print_r($r);//result

Python code:

#! /usr/bin/env python
import html2text
import sys
#print html2text.html2text(sys.stdin.read()) #this part of the code didn't work out...
print html2text.html2text(sys.argv[1])

Result:

Array
(
    [0] => **Hello**_world!_
    [1] => 
    [2] => 
)

All the files are in the same directory (under chmod 077). I am using Aaron Swartz’s html2text.py version 2.39 and also installed “python-html2text.noarch” on my Fedora 14 (though I couldn’t make it work with this last one).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:58:52+00:00Added an answer on May 19, 2026 at 4:58 am

    You’re just passing the last line to html2text , and you are not using html2text correctly do this instead :

    import html2text
    import sys
    
    print html2text.html2text(sys.stdin.read())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having some trouble sending properly formatted HTML e-mail from a PHP script. I am
I have an HTML form - with PHP, I am sending the data of
I can't seem to retrieve an ID I'm sending in a html.ActionLink in my
I am sending out an email, and the message ($message) is in HTML I
Sending a message from the Unix command line using mail TO_ADDR results in an
M sending the parameters from the jsp page, the code is <s:url id=url action=searchAction>
I'm looking into sending regular automated text-messages to a list of subscribed users. Having
I'm sending mail from my C# Application, using the SmtpClient. Works great, but I
I am getting an error while sending a mail from a form Failed to
I'm having an issue with a simple PHP mailer. I've had this script working,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.