Managing wordpress blog with python inside terminal

Recently proxy support was added to [python-wordpress-xmlrpc( library. Based on this library, I was able to clean-up my old scripts to communicate with wordpress via xmlrpc client. This client read the environment variable http_proxy. One can use also use --proxy in command line. Set the http_proxy variable in bash file and source ~/.bashrc. Here is the repository of this script. This package is also available on pypi as twordpress. I can not think of a better name. Use pip to install the package. I will assume that you have installed the package using pip or python install command. This repository contains working version of python-wordpress-xmlrcp library of Max Cutler). It uses pandoc to convert markdown to html and vice versa. Since pandoc is very versatile tool, I removed script of late Aron Swartz. Unfortunately pandoc is not python based and installing it would bring in whole Haskell stuff (who care inside IIT about installing). It does not work with python3.

Config file

You need to create ~/.wordpressrc file with entries shown below. If you want to keep this config file in some other location, you can pass the location to the script by using --config filename argument.


Blog [blog0] is default blog.


  • To fetch all blogs from blog0twordpress –blog 0 –fetch all
  • To fetch blog with matching titles. .twordpress –blog 0 –fetch “some pattern”
  • To fetch recent posts from default blog (i.e. blog0)twordpress

Change the --blog 0 to --blog 1 to work on blog1. It will create a directory for each post and save the content in (markdown) format inside that directory. A html file content.html is also generated for your reference. Later version might support sending html file to wordpress so that one can generate his own html file from the tool he likes.

Edit and post

Edit the download, and run the following command

 ./twordpress --blog 0 --update

(Make sure to give the right blog no). For a new post. Create a new post with header similar to one of the file. An example is following.

Creating new post

A minimal post looks like following.
title: My awesome post
status: publish
My awesome content.


Metadata of post is stored at the beginning of the post between ~~~ tags. This is jekyll format of writing post. If one is managing github-pages, the same post can be posted to wordpress. One can edit the metadata to change the status of post from ‘publish’ to draft etc. More tags can be added or deleted. Same with categories. Following features are most likely to be added soon.

  • Downloading media for each post.
  • Ability to embed offline media in markdown file.
  • Dilawar

About Dilawar

Graduate Student at National Center for Biological Sciences, Bangalore.
This entry was posted in NoGuiNoMouseNoProblem and tagged , . Bookmark the permalink.