Blogger Migration Part II: Getting Data Into Blogger #

Blogger doesn't have any built-in entry importing facilities. My plan for dealing with this was to use their API to re-post all of the entries I had exported from Movable Type. A quick test showed that such entries could be back-dated, which was my main concern.

Using some sample code that I found as a starting point, it was pretty easy to write a simple importing script for entries. Since I needed to parse the Atom responses from the API (e.g. to get at entry IDs), the Universal Feed Parser came in handy. Since I had used the Convert Line Breaks option on quite a few posts, I had to HTML-ify some post bodies before sending them to Blogger (I've turned off Blogger's similar setting. In addition to being only at the blog level, instead of a per-post setting, I've decided that the closer to regular HTML my posts are, the easier it will be to migrate again in the future).

The Blogger API allows for posting of comments too, but unfortunately without the ability to impersonate others (even when anonymous comments are enabled). The solution was to impersonate the regular (non-API) comment posting form, which does allow for authors to be specified (but no backdating, which is why all imported comments are dated February 10th). This was made slightly trickier since a security token is required (to avoid XSRF attacks), so the posting page had to be scraped first to extract it.

Finally, since Blogger proved to be occasionally flaky when doing many API operations in a row, I had to add some simple checkpointing so that if the process failed I could restart it and it would continue from where it left off. Once I did all that, importing 350+ entries and 600+ comments took around an hour, but worked flawlessly.

I've uploaded an archive of my code that I used for the importing. It's not the cleanest it could be, but others may find it useful too. Additionally, in the time that has passed since I began my importing, it looks like a similar script has appeared that does a similar import operation from WordPress, which may be worth a look too.

4 Comments

I like to use exclusively Google services too, but I haven't been too impressed with Blogger. The new layout tool is nice, but there are still ridiculous problems like broken tab order on the comments page, and I haven't found any way to get in touch with them, unlike how responsive you guys are in your Google group.
I would like to see in built support for linking blogger to digg, del.icio.us, et al
I have no idea how you did 350+ entries in an hour. My atom importer script got stopped by the 41st entry, and I got that "word verification" thingy sticking out now.

Blogger apparently doesn't like people migrating to Blogger. Maybe wordpress will accept me...
very useful blog and nice job! thank you!

my question is: can you point to some two-column blogspot template (not necessarily yours).

i was absolutely fascinated to find this at your blog!

i hope asking this sort of questions is not a crime! :) and thanks in advance!

Post a Comment