I have a WordPress website and I want to send some specific posts using python. When my posts includes no non-latin character, I have no problem, I can easily publish them.
However, when I use characters like ‘Ä’ or ‘Å’ in my post, it gives me a parse error. not well formed
error. I have to use iso-8859-9 encoding due to language of my site and I couldn’t solve this problem no matter what I’ve tried.
Here is my code:
# -*- coding: iso-8859-9 -*-
from wordpress_xmlrpc import Client
from wordpress_xmlrpc.methods import posts
from wordpress_xmlrpc import WordPressPost
wp = Client('http://websiteurl/xmlrpc.php', 'username', 'pass')
#posts = wp.call(posts.GetPosts())
#print posts[0]
data="GüneÅ doÄudan doÄar"
post = WordPressPost()
post.title = 'My Post Title'
post.content = data
post.id = wp.call(posts.NewPost(post))
post.post_status = 'publish'
wp.call(posts.EditPost(post.id, post))
data
is already encoded asiso-8859-9
, so you’ll want todecode()
it in order to pass it through to WordPress. The problem line ispost.content = data
. You’ll want to change it to: