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
- MetaWeblog API (included in wordpress, there is nothing to install)
- XML-RPC Support in wordpress (announcement about the list of supported blog APIs on wordpress)
- Python XML-RPC library documentation
- The Atom API (he talks about the MetaWeblog API too)
- Post WordPress entry with Python (an example how to send a post with Python)
- Using Blog API’s (list of blog API methods that are supported on wordpress)
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.
Leave a Reply Cancel reply
Blog Stats
- 312,889 hits
Random Post
Recent Posts
Tags
Categories
Blogs that I follow
Archives
- May 2013 (9)
- April 2013 (20)
- March 2013 (10)
- February 2013 (7)
- January 2013 (26)
- December 2012 (18)
- November 2012 (13)
- October 2012 (9)
- September 2012 (8)
- August 2012 (7)
- July 2012 (3)
- June 2012 (9)
- May 2012 (16)
- April 2012 (32)
- March 2012 (18)
- February 2012 (17)
- January 2012 (12)
- December 2011 (8)
- November 2011 (18)
- October 2011 (18)
- September 2011 (32)
- August 2011 (13)
- July 2011 (16)
- June 2011 (6)
- May 2011 (14)
- April 2011 (30)
- March 2011 (45)
- February 2011 (42)
- January 2011 (28)
- December 2010 (14)
- November 2010 (29)
- October 2010 (15)
- September 2010 (5)
You can also use https://github.com/charlax/wordpresslib !
A similar one: https://github.com/maxcutler/python-wordpress-xmlrpc.