Home > python, wordpress > Get the list of your posts on wordpress.com with a Python script using the MetaWeblog API

Get the list of your posts on wordpress.com with a Python script using the MetaWeblog API

Problem

You have a blog on wordpress.com and you want to get the list of your posts. For this task, you want to use a Python script.

Solution

#!/usr/bin/env python

import xmlrpclib
import sys
import pprint

pp = pprint.PrettyPrinter(indent=4)

# you can use the HTTP or the HTTPS protocol below:
server = xmlrpclib.ServerProxy('https://NAME_OF_YOUR_BLOG.wordpress.com/xmlrpc.php')
result = server.metaWeblog.getRecentPosts('NAME_OF_YOUR_BLOG', 'USER_NAME', 'USER_PASSWORD', sys.maxint)
pp.pprint(result)
print
print 'Number of posts: %d.' % len(result)

The script will download the list of all your posts. If you want, for instance, the latest 20 posts, write 20 instead of sys.maxint.

Links

What next?

I would like to have an “Archives” page that would list the titles of my posts. This way, I could find the post I’m looking for much easier. Unfortunately I didn’t find this functionality on wordpress.com. I was searching for a solution and I found WordPress ListMaker v2. However, the author provides an EXE only and his program requires your username. This is something I would never give out… On the other hand, I use Linux, so I prefer open source solutions.

So the next project is to complete the Python script above to produce an HTML output, similar to WordPress ListMaker v2. I’ll do it when I have some free time.

Update (20110223): The script is ready, see this post.

About these ads

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 73 other followers

%d bloggers like this: