So occasionally during my regular work over on the TechInAsia.com blog, some repetitive or monotonous task arises that could be potentially automated somehow. Up until now, my toolbox to take these tasks on has been really limited, but my python skills are beginning to shape up so that I can actually implement some automation to take care of simple tasks.
Here's a simple script that I was working on yesterday, which returns a list of posts for a contributing writer in a given month, along with a word count for each post. It's a modification of a script by Nick Zarczynski, which he created from a Jabba Laci script.
Standing on shoulders is cool...
Anyway, when Nick left off, the script would return three things:
- total posts
- total words
- average words per post
My version after a little bit of tweaking now returns a list of posts in a given month (for my purposes, that will be the most recent month), along with the date it was created, and the word count for that post. It also implements a conditional so that we only get posts for a specific user, rather than all recent posts on the blog. An example of the output is here, which is my list of articles for October.
Update: Because the wordcount did not previously account for images and other non-text elements in body, I've enlisted the help of the Beautiful Soup module to get around that. So far, so good!
My code is still far to ugly to be showing in public... But in the interests of learning, I'll occasionally post some of it. ↩