Tag Archives: wordpresslib

wordpressWordPress is probably the best blogging software out there. This site runs on WordPress. It’s easy to install, amazingly extensible with themes and plugins and very easy to use. In fact the vast majority of the websites I maintain run on WordPress.

wordpresslib is a Python library that makes it possible to programatically put new content onto a blog. It works with both the self-hosted as well as the freely hosted wordpress.com blogs and It gives you the power to do these tasks:

  • Publishing new post
  • Editing old post
  • Publishing draft post
  • Deleting post
  • Changing post categories
  • Getting blog and user informations
  • Upload multimedia files like movies or photos
  • Getting last recents post
  • Getting last post
  • Getting Trackbacks of post
  • Getting Pingbacks of post

When used in conjunction with some of the other scripts I have shared on this site such as Getting Ezine Article Content Automatically with Python, Translating Text Using Google Translate and Python, How To Get RSS Content Into An Sqlite Database With Python – Fast it is possible to build a very powerful blog posting robot.

Here’s an example of just how simple it is to send a new post to a wordpress blog:

import wordpresslib
 
def wordpressPublish(url, username, password, content, title, category):
 
	wp = wordpresslib.WordPressClient(url, username, password)
	wp.selectBlog(0)
 
	post = wordpresslib.WordPressPost()
	post.title = title
	post.description = content
	post.categories = (wp.getCategoryIdFromName(category),)
 
	idNewPost = wp.newPost(post, True)

I make use of this on a daily basis in various scripts I have that re-purpose content from other places and push it onto several aggregation blogs that I have. Over the next few posts I’ll be revealing exactly how that system works so stay tuned. (and make sure you’re subscribed to the RSS feed)