Scripting does the trick!

Last night I finally googled around and found http://python-wordpress-xmlrpc.readthedocs.org/en/latest/. This library uses WordPress’s XML-RPC API hook to let you connect, fetch content, and make edits. It was fabulous!

Having migrated from Blogger, I still had a huge number of links that were pointed at Picasaweb, where I have images stored. I had wanted to somehow update all my old blog posts and point them at the images I pulled down from Picasaweb and uploaded here.

This library was perfect. Their intro docs show you the basics of how to get started. It wasn’t long before I figured out how to scan every post, look for particular patterns I wanted to clean up, and then replace them properly. For example, my blog used to be greg-turnquist.blogspot.com. Several of my posts were still linked as such. Blogger kindly would forward uses hitting those links, and I left sufficient settings behind so they would keep getting redirected here. But to finally erase that old domain from all cross posted blog entries was perfect.

The other thing that I need to wrap up is how I still have some blog entries that hyperlink to the old label system of blogger (/search/labels/foobar). In WordPress, I use /category/foobar, so I need to scan for them all and make updates. I also need to replace things like real%20estate with real-estate.

The library even had the ability to pull down information on every image uploaded to this site. I naturally checked the name of each image here and on Blogger, and they all have the same root filename. I just needed to update the link and URI path.

To top things off, as usual, I dug up Python’s formidable re library. I always have to pull up the reference docs. Something about regular expressions always requires me to reboot my brain on using it. I am quite skilled and have been writing regular expressions since I learned PERL probably twenty years ago. But to really sink your teeth into a problem, write the correct pattern, and extract the groups through their API…well, let’s just say it doesn’t stick to me quite like certain other things. No doubt, this site helped me craft the pattern I needed.

After all was said and done, I finally pulled the trigger and issued a handful of edits. In no time, I had updated both this blog and my financial one, ensuring that I was now using local images.

Leave a Reply

Your email address will not be published. Required fields are marked *