Export Blogger Blogs to BlogML with PowerShell

Posted July 21st @ 12:47 am by aaron

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:

Blogger-Profile

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.
BlogExportInProgress

BlogExportCompleted

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: ,

2 Trackbacks/Pingbacks

  1. Pingback: Breaking Up: Moving Blog Engines | Aaron Lerch on August 23, 2007
  2. Pingback: BlogML to WordPress Importer - Keyvan Nayyeri on August 24, 2007

9 Comments

  1. aaron
    August 22, 2007 at 23:29

    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!

  2. Sarah Michele
    August 22, 2007 at 23:29

    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?

  3. Don Worthley
    November 7, 2007 at 14:35

    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.

  4. aaron
    November 7, 2007 at 14:41

    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”

  5. Chris
    December 11, 2007 at 19:24

    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…

  6. Christia
    December 30, 2007 at 23:42

    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!

  7. aaron
    December 31, 2007 at 00:25

    @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.

  8. Grimace
    January 21, 2008 at 11:02

    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 :)

  9. aaron
    January 21, 2008 at 11:07

    Thanks Grimace - no reference to me is necessary… Thanks for asking, though!

Leave a comment

OpenID Login

Standard Login

Options:

Size

Colors