Export Blogger Blogs to BlogML with PowerShell
I’m in the process of moving my blog from Blogger to WordPress, and I’m finding out just how important a project like BlogML really is. Most blog engines will integrate with a select few other engines to allow importing/exporting. What we really need is something just like BlogML – a standard format describing blog metadata that allows maximum interoperability. I’d love it if I could change my blogging engine periodically to get the best feature set for my ever-changing needs. But at this rate, the pain and effort is not really worth it.
My frustration led me to create a PowerShell script to export a Blogger blog to BlogML. Other methods exist, but they all required changing something about my blog, whether it was the template, or the hosting (and thus domain name). Not gonna happen. The script makes use of the BlogML .NET library (for ease) and the Blogger API. No Blogger login is required, you simply have to specify your “userid”. Your user id (it’s most likely public) can be found in your profile URL, like so:
Once you get that id, just run the script and pipe the output to a file. The output is actually an array of strings, each one is BlogML XML that represents a single blog. You can have multiple Blogger blogs associated with your user account–this will automatically download all of them. You can change the script not to do that if you need to.
To use it, type the following at the command line, I’m using my user id as an example (and I know I only have a single blog):
PS C:\Test> .\BloggerToBlogML.ps1 “17257708406345880368″ | out-file aaronlerch.blogml.xml
You’ll get a progress bar as it downloads your posts, and when it’s completed it shows a short summary.
![]()
Download the script here, or from my Garage Sale Code page. Let me know of any bugs or improvements I can make–I made it do what I needed, and not much more (the Blogger API is a little sparse anyway), but I’m happy to update it to include more if someone has a need.
Technorati Tags: powershell, blogml
August 22nd, 2007 at 11:29 pm
Thanks!
Assuming you were running this on your blogs, it probably downloaded your public one successfully, but balked when it tried to download your protected one. I didn’t put in any code to authenticate with the Google API–I bet if I added that it would work on the 2nd blog. As a workaround, if you’re not interested in your restricted blog, you could hack the script to only load the correct one (hard-coded, or whatever).
Sometime when I get some time (not in the next two weeks, sorry
) I’ll take a look and see about doing some authentication.
Thanks!
August 22nd, 2007 at 11:29 pm
Sweet script!!!
Seems to have generated the xml just fine.
However, I did get this error at the end.
Exception calling “DownloadString” with “1″ argument(s): “The remote server returned an e
At C:\Documents and Settings\Administrator\Desktop\BloggerToBlogML\BloggerToBlogML.ps1:10
+ $blogPostList = [xml](new-object System.Net.WebClient).DownloadString( < <<< $url)
Any ideas?
August 23rd, 2007 at 2:49 pm
[...] actually already posted on this here. I decided on BlogML as my “offline” format for my blog, and wrote a PowerShell script [...]
August 24th, 2007 at 12:15 am
[...] in July, I wrote about the PowerShell script that Aaron Lerch had designed to export Blogger content to BlogML in order to migrate his blog [...]
November 7th, 2007 at 2:35 pm
Awesome script. Very helpful.
I had to set the execution policy as follows since this was my first PowerShell script! Woohoo!
I set the policy as follows:
Set-ExecutionPolicy RemoteSigned
In case others run into this same problem, it still balked at the script by throwing the following error:
The term ‘BloggerToBlogML.ps1′ is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.
I created a new text file, copied the script from your file into the new file and it ran fine, maybe because of the security related to scripts that are downloaded from the internet? I’m not sure, but it worked fine after that.
November 7th, 2007 at 2:41 pm
Thanks Don!
As an FYI, you can also run this command (from a command prompt, not powershell) instead of copying the text into a new file. You’re right, it does get marked as “downloaded”.
Run the following:
“echo on > BloggerToBlogML.ps1:Zone.Identifier:$DATA”
December 11th, 2007 at 7:24 pm
Have you seen BlogEngine.net? Written in C# and completely free. Not to mention that the guys working on the code are extremely interactive and helpful…
December 30th, 2007 at 11:42 pm
Hi Aaron, I was so happy to find your solution to my problem. But when I tried running the script from cmd, WindowsXP complains that it doesn’t know what program can be used to run it -_-”. May I know how can I resolve this?
Thanks!
December 31st, 2007 at 12:25 am
@Christia
My script is a PowerShell script, which requires Windows PowerShell in order to run. That is, you’ll need to install PowerShell, and then run this script from within the PowerShell command prompt. You can install PS from this URL:
http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx
Hope it works out for you.
January 21st, 2008 at 11:02 am
I’ve taken the freedom to read your script and subsequently bake my own app with this knowledge. No need for PowerShell, but .NET 2.0 required: http://sourceforge.net/projects/blogexporter/
Let me know if you have any objections or want to be mentioned in some special way (I did enter a reference somewhere, but I can’t find it anymore
January 21st, 2008 at 11:07 am
Thanks Grimace – no reference to me is necessary… Thanks for asking, though!
November 23rd, 2008 at 7:26 pm
I opened the script and saw the MAXPOSTRESULTS variable and changed that to be high enough to accommodate our total. When I ran the script, I got “retrieval completed with 500 posts”. That’s way short of how many posts we really have, so is that some sort of hardcoded limit in Google’s API? If so, can the posts be retrieved in chunks instead?