Bill on the Soldersmoke blog posted recently with some concern that one day Google might lose interest in their free blogging platform Blogger. I share his concern and wanted to assure myself that there's a way to move all of my posts, images and comments to something else, most likely Wordpress, if suddenly required to.
After much searching around there don't seem to be many options. One is a promising looking Wordpress plugin btw-importer by mnasikin. It's not in the plugin directory but you can download the zip and install it.
This is probably the way to go in the end but currently it doesn't migrate comments. I've reported a few bugs and mnasikin has been very responsive. He even accepted a tiny pull request from me to at least skip comments for now, rather than turning them in to posts.
Wordpress has a very nice REST API and I can see some python code around that makes a nice wrapper for it. I asked Anthropic Claude to write me python to read the Google takeout feed.atom file and migrate posts, images and comments over to Wordpress and it did a pretty good job. I fixed a few bugs but it's working well enough to be a good start.
I've stuck my (our?) code up as a Github gist: blogger2wordpress.py and I hope it helps someone (maybe future me).
Here's a migrated post:
Here's the comments:
Looks pretty good although, undoubtedly there are bugs.
Update: Blocked by Mod_Security
I tried all this on an Ubuntu virtual machine at home and it worked fine. When I tried on a hosted Wordpress site I got this error:
Processing entry 9/20: Why the 30 Meter Pipeline to Norway?
Error creating post: 406
Response: <head><title>Not Acceptable!</title></head><body><h1>Not Acceptable!</h1><p>An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security.</p></body></html>
✗ Failed to create post: Why the 30 Meter Pipeline to Norway?
It seems that Mod_Security doesn't like the Wordpress API being used.
Several days went by trying to get the support people to turn off Mod_Security. Next I ran the script and it transferred 206 posts, categories, comments and images before the host stopped responding. I'm not sure what happened - perhaps some sort of rate limit, or a maximum traffic issue. The host had DDoS protection so it's possible that was triggered.
The script had a one second pause between posts but this wasn't enough and I raised it to five seconds. I still saw a few errors with posts, comments and images. Some were complaints about illegal characters, some images were not liked by Wordpress - I don't know why.
In any case it looks like this script works well enough. Here's the end of the run which went for about 36 hours:
Migration complete!
Posts - Successful: 3757, Failed: 2, Total: 3759
Comments - Successful: 8561, Failed: 324, Total: 8885
Images processed: 3861
Cleanup completed