Post HTML data via XMLRPC in Python?

I am writing a small script by Python to connect and post content to my WordPress blog. It’s pretty straightforward with https://github.com/maxcutler/python-wordpress-xmlrpc

However, when i tried to input a HTML data, for example:

Read More
<b>Hello</b>

It appears exactly in the WordPress post (I watch it from the visual editor, and I need to re-format it by copying the data to HTML mode to have the expected result.

What should I do with my python script ?

Thank you very much

Related posts

Leave a Reply

1 comment

  1. Could the HTML data you are uploading already have its angle brackets escaped into HTML entities? I.e. < becomes &lt; while > becomes &gt;

    This would lead to the behavior you describe. The visual editor would show what looks like raw HTML, not the result of rendering HTML.

    To fix, either (i) prevent that encoding, or (ii) the quick and dirty approach, do a search and replace on the HTML before handing to your API. Something along the lines of:

    html = html.replace('&lt;', '<')
    html = html.replace('&gt;', '>') 
    

    should do the trick.