Skip to main content

Ralsina.Me — Roberto Alsina's website

Migrating from Haloscan to Disqus (if you can comment on it, it worked ;-)

Introduction

If you are a Haloscan user, and are start­ing to won­der what can you do... this page will ex­plain you a way to take your com­ments to Dis­qus, an­oth­er free com­ment ser­vice.

A few days ago, Haloscan an­nounced they were stop­ping their free com­ment ser­vice for blogs. Guess what ser­vice has in it the com­ments of the last 9 years of this blog? Yes, Haloscan.

They of­fered a sim­ple mi­gra­tion to their Echo plat­for­m, which you have to pay for. While Echo looks like a per­fect­ly nice com­ment plat­for­m, I am not go­ing to spend any mon­ey on this blog if I can help it, since it al­ready eats a lot of my time.

Luck­i­ly, the guys at Haloscan al­low ex­port­ing the com­ments (that used to be on­ly for their pre­mi­um ac­counts), so thanks Haloscan, it has been nice!

So, I start­ed re­search­ing where I could run to. There seems to be two large free com­ment sys­tem­s:

Keep in mind that my main in­ter­est lays in not los­ing al­most ten years of com­ments, not on how great the ser­vice is. That be­ing said, they both seem to of­fer rough­ly the same fea­tures.

Let's con­sid­er how you can im­port com­ments to each ser­vice:

  • Dis­­qus: It can im­­port from blog­ger and some oth­­er host­ed blog ser­vice. Not from Haloscan.

  • In­­tense De­­bate: Can im­­port from some host­ed ser­vices, and from some files. Not from the file Haloscan gave me.

So, what is a guy to do? Write a python pro­gram, of course! Here's where Dis­qus won: they have a pub­lic API for post­ing com­ments.

So, all I have to do then is:

  1. Grok the Dis­­qus API

  2. Grok the Haloscan com­­ments file (it's XM­L)

  3. Cre­ate the nec­es­sary threads and what­ev­er in Dis­­qus

  4. Post the com­­ments from Haloscan to Dis­­qus

  5. Hack the blog so the links to Haloscan now work for Dis­­qus

Piece of cake. It on­ly took me half a day, which at my cur­rent rates is what 3 years of Echo would have cost­ed me, but where's the fun in pay­ing?

So, let's go step by step.

1. Grok the Disqus API

Luck­i­ly, there is a rea­son­able Dis­qus Python Client li­brary and docs for the API so, this was not hard.

Just get the li­brary and in­stall it:

hg clone https://IanLewis@bitbucket.org/IanLewis/disqus-python-client/
cd disqus-python-client
python setup.py install

The API us­age we need is re­al­ly sim­ple, so study the API docs for 15 min­utes if you wan­t. I got al­most all the tips I need­ed from this py­blox­som im­port script

Ba­si­cal­ly:

  1. Get your API Key

  2. You lo­­gin

  3. You get the right "fo­rum" (y­ou can use a dis­­qus ac­­count for more than one blog)

  4. Post to the right thread

2. Grok the Haloscan comments file

Not on­ly is it XM­L, it's pret­ty sim­ple XM­L!

Here's a taste:

<?xml version="1.0" encoding="iso-8859-1" ?>
<comments>
    <thread id="BB546">
      <comment>
        <datetime>2007-04-07T10:21:54-05:00</datetime>
        <name>superstoned</name>
        <email>josje@aaaaaa.nl</email>
        <uri></uri>
        <ip>86.92.111.236</ip>
        <text><![CDATA[that is one hell of a cool website ;-)]]></text>
      </comment>
      <comment>
        <datetime>2007-04-07T16:14:53-05:00</datetime>
        <name>Remi Villatel</name>
        <email>maxilys@aaaaaa.fr</email>
        <uri></uri>
        <ip>77.216.206.65</ip>
        <text><![CDATA[Thank you for these rare minutes of sweetness in this rough world...]]></text>
      </comment>
    </thread>
</comments>

So, a com­ments tag that con­tains one or more thread tags, which con­tain one or more com­ment tags. Piece of cake to tra­verse us­ing El­e­ment­Tree!

There is an ob­vi­ous match be­tween com­ments and threads in Haloscan and Dis­qus. Good.

3. Create the necessary threads and whatever in Disqus

This is the tricky part, re­al­ly, be­cause it re­quires some things from your blog.

  • You must have a per­ma­link for each post

  • Each per­ma­link should be a sep­a­rate page. You can't have per­ma­links with # in the URL

  • You need to know what haloscan id you used for each post's com­­ments, and what the per­ma­link for each post is.

For ex­am­ple, sup­pose you have a post at //ralsi­na.me/we­blog/­post­s/AD­V0.html and it has a Haloscan com­ments link like this:

<a hre­f="javascrip­t:HaloScan('AD­V0');" tar­get="_­self"> <script type­="­tex­t/­javascrip­t">­post­Coun­t('AD­V0');</scrip­t></a>

You know where else that 'AD­V0' ap­pears? In Haloscan's XML file, of course! It's the "id" at­tribute of a thread.

Al­so, the ti­tle of this post is "Ad­voga­to post for 2000-01-17 17:19:57" (hey, it's my blog ;-)

Got that?

Then we want to cre­ate a thread in Dis­qus with that ex­act same da­ta:

  • URL

  • Thread ID

  • Ti­­tle

The bad news is... you need to gath­er this in­for­ma­tion for your en­tire blog and store it some­where. If you are luck­y, you may be able to get it from a database, as I did. If not... well, it's go­ing to be a lot of work :-(

For the pur­pose of this ex­pla­na­tion, I will as­sume you got that da­ta nice­ly in a dic­tio­nary in­dexed by thread id:

{
  id1: (url, title),
  id2: (url, title)
}

4. Post the comments from Haloscan to Disqus

Here's the code. It's not re­al­ly test­ed, be­cause I had to do sev­er­al at­tempts and fix­es, but it should be close to ok (down­load).

#!/usr/bin/python
# -*- coding: utf-8 -*-

# Read all comments from a CAIF file, the XML haloscan exports

from disqus import DisqusService
from xml.etree import ElementTree
from datetime import datetime
import time


# Obviously these should be YOUR comment threads ;-)
threads={
    'ADV0': ('//ralsina.me/weblog/posts/ADV0.html','My first post'),
    'ADV1': ('//ralsina.me/weblog/posts/ADV1.html','My second post'),
    }

key='USE YOUR API KEY HERE'
ds=DisqusService()
ds.login(key)
forum=ds.get_forum_list()[0]

def importThread(node):
    t_id=node.attrib['id']

    # Your haloscan thread data
    thr_data=threads[t_id]

    # A Disqus thread: it will be created if needed
    thread=ds.thread_by_identifier(forum,t_id,t_id)['thread']

    # Set the disqus thread data to match your blog
    ds.update_thread(forum, thread, url=thr_data[0], title=thr_data[1])


    # Now post all the comments in this thread
    for node in node.findall('comment'):
        dt=datetime.strptime(node.find('datetime').text[:19],'%Y-%m-%dT%H:%M:%S')
        name=node.find('name').text or 'Anonymous'
        email=node.find('email').text or ''
        uri=node.find('uri').text or ''
        text=node.find('text').text or 'No text'

        print '-'*80
        print 'Name:', name
        print 'Email:', email
        print 'Date:', dt
        print 'URL:', uri
        print
        print 'Text:'
        print text

        print ds.create_post(forum, thread, text, name, email,
                                   created_at=dt, author_url=uri)
        time.sleep(1)

def importComments(fname):
    tree=ElementTree.parse(fname)
    for node in tree.findall('thread'):
        importThread(node)


# Replace comments.xml with the file you downloaded from Haloscan
importComments('comments.xml')

Now, if we are luck­y, you al­ready have a nice and ful­ly func­tion­ing col­lec­tion of com­ments in your Dis­qus ac­coun­t, and you should be calm know­ing you have not lost your da­ta. Ready for the fi­nal step?

Hugh Isaacs II / 2009-12-18 09:06:

Echo is free (I use it on one of my blogs and haven't paid yet).

Roberto Alsina / 2009-12-18 11:03:

It's not going to be free anymore: http://js-kit.com/pricing/

Paolita / 2010-01-14 22:26:

por favor serias tan amable de ayudarme a llevar mis comentarios de haloscan a DISQUS, ya subi la plantilla pero ahora no me paarece ningun coments,claro yo tengo mi plantilla original bien guardada, x otra parte tambien tengo en mi pc los coments exportados en formato xml de haloscan estuve viendo en tools de disqus pero hago lo me dice igual no consigo integrar mis ocmnets de haloscan a disqus HELPPPPPPPPPPPPPPPPP

Roberto Alsina / 2009-12-18 11:23:

Hey, talk about timing, just got the "upgrade in the next 15 days or your comments die" email from Haloscan two hours after posting :-)

Sorry guys, no need!

Roberto Alsina / 2009-12-18 14:15:

Thinking a bit more about this: If you have a list of permalinks, then generating the list of Haloscan IDs and titles is just a matter of programming and screen-scraping.

Margaret / 2010-02-02 23:10:

The biggest missing link seems to be that you need a cross reference listing that links the Haloscan ID to the permalink (because Disqus requires a permalink in it's upload, whereas the Haloscan export XML file only provides a Haloscan ID). The question is, now that Haloscan no longer provides the "Manage Comments" page, is there another way that you're aware of to automatically get this relationship, or will I have to manually go in and identify the permalink for each Haloscan ID?

Roberto Alsina / 2010-02-03 11:26:

I could get it automatically because I knew exactly how each haloscan ID was generated (it was basically a post's internal ID). For other systems, well, it is going to be manual labour.

OTOH, it can be done gradually, it doesn't have to be done all at once.

Margaret / 2010-02-03 20:13:

Thanks Roberto!

DavidGross / 2009-12-18 23:50:

Disqus claims to have an "import" feature that supports js-kit, but so far I haven't had any luck (it claims to have imported the data, but no actual comments show up on the "Moderate" page).

While I've got your attention... anyone know of a good strategy to make Disqus work with an XHTML-Strict site served as application/xml+xhtml? Their javascript relies on document.write(), which won't work in such a case.

Roberto Alsina / 2009-12-19 00:19:

ISame thing happened here, it "imported" in minutes but nothing appeared. Probably the wrong flavor of XML or something.

sandyxxx / 2009-12-19 09:54:

but .from now on ,i know that ,there still have some one care of the comment which have wealth of information.

am i right?

Hot deals--

obscurelyfamous / 2009-12-20 23:36:

Hi Robert (and everyone else)!

Thanks for the writeup. Over at Disqus, we're working quickly to better support people coming over from Haloscan. Disqus is a free (as in pricing) alternative to Haloscan that you may want to check out.

Let me know if you need any help.

--@danielha on Twitter

Roberto Alsina / 2009-12-20 23:44:

It's working pretty well, thanks!

JoeJoomla / 2009-12-21 13:54:

That's very impressive what you did Roberto. Most people who blog would not be capable of migrating their comments to another system.

How long before Disqus puts their free users in the same situation as Echo and start charging for their service?

Roberto Alsina / 2009-12-21 15:19:

Well, it's the second time I do this. This blog was first hosted at a free service that included comments (pycs.net).

When that died, I switched to static hosting plus haloscan.

Now, because haloscan died, it's static hosting plus disqus.

Should disqus die too, it would probably have to be a personal djangocomments thing or whatever.

So far, I had to move the comments twice in six or seven years, so it's not exactly a common event (The first two/three years I used advogato that's way more limited).

JoeJoomla / 2009-12-21 16:23:

What if Disqus decided next week to change their free service to a fee service? We don't know if or when this might happen. Hopefully it won't happen. I suppose that is the risk everyone takes in using anything offered for free.

It's often the criticism that I get for choosing Disqus when there are free commenting components available right in the open source blog system that I am using.

Is offering commenting systems for free simply a business tactic to build up a potential customer base for future paid fee services?

Roberto Alsina / 2009-12-21 17:33:

Then I migrate again, this time to something I host myself, or maybe something I hack on app engine. No big deal.

That'sthe good side of being a programmer. Computers do what I tell them to do.

ugg boots / 2009-12-26 07:36:

Then I migrate again, this time to something I host myself, or maybe something I hack on app engine. No big deal.

That'sthe good side of being a programmer. Computers do what I tell them to do.

ugg boots / 2009-12-26 07:36:

Then I migrate again, this time to something I host myself, or maybe something I hack on app engine. No big deal.

That'sthe good side of being a programmer. Computers do what I tell them to do.

prosto2 / 2010-01-05 22:31:

cool i like this post! It's amazing! thanks a lot!

polochniestelazi / 2010-01-07 12:45:

thanks a lot, very nice post!

Change-of-Address / 2010-01-09 19:26:

Wow. That's a lot of work to move comments over from Haloscan. When you were comparing Disqus and Intense Debates, did you happen to look into how difficult it might be to migrate off those platforms when you moved onto them? Just a thought...

Roberto Alsina / 2010-01-11 13:30:

Yes, basically there is no way to migrate them to intense debate at all, as far as I can see.

uggboots / 2010-01-10 08:18:

Thanks for the writeup. Over at Disqus, we're working quickly to better support people coming over from Haloscan. Disqus is a free (as in pricing) alternative to Haloscan that you may want to check out.

Let me know if you need any help.

wholesale Electronics / 2010-01-14 03:58:

I like disqus blog comments

Paolita / 2010-01-14 22:24:

por favor serias tan amable de ayudarme a llevar mis comentarios de haloscan a DISQUS, ya subi la plantilla pero ahora no me paarece ningun coments,claro yo tengo mi plantilla original bien guardada, x otra parte tambien tengo en mi pc los coments exportados en formato xml de haloscan estuve viendo en tools de disqus pero hago lo me dice igual no consigo integrar mis ocmnets de haloscan a disqus HELPPPPPPPPPPPPPPPPP

Roberto Alsina / 2010-01-14 22:37:

Con ponerlo una vez era suficiente :-(

Después te contacto por mail para ver como hacemos.

Paolita / 2010-01-14 22:52:

sorry, es q no me salia publicado x eso intente varias veces :(

PD: ahy te dejo mis ubicaciòn

thesis writer / 2010-01-26 18:25:

Io sono per il Disqus e anche la mia società di utilizzare questo sistema con le pagine internet

Nina / 2010-01-28 14:42:

Hi, this is a great post. I've been also trapped in this situation with the end of Haloscan, and have exported 5 years of comments. Disqus seams great but I'm afraid that the same thing might happen to Disqus in the future, so I'm more likely to pass to Blogger comments, although I'm not such a great fan... Do you have any clue if it is possible to import the Haloscan comments to Blogger, and how?

Roberto Alsina / 2010-01-28 14:48:

Well, if blogger has an API for comments, then you can use half of this post for reading the haloscan data, and then post it into blogger somehow.

Bill / 2010-01-29 12:47:

I am thesis writer and used your article in my dissertation!
Thanks)

Linking / 2010-01-29 14:39:

This article is very good. Useful to me. I will return to read this article and other article absolute sure. thank you
For my site Linking

Jewellery Tips / 2010-02-10 16:22:

This is great story but I more likely to pass to Blogger comments with the help of DISQUS. I like DISQUS blog comments. because DISQUS is a free commenting plug-in..

Gucci Sunglasses / 2010-02-15 02:08:

I was looking for a post related to moving the comments from Haloscan to Disqus, and at last I found it. Thanks

John Lee / 2010-02-15 21:34:

I like this blogs because DISQUS also works with many different platforms Users also don’t have to sign up for DISQUS or your blog to post comments. You can use your login credentials from another service like Yahoo, Twitter, Open-ID, and others and share the comments...

truja / 2010-02-24 14:25:

Este metodo es muy dificil.. alguien encontro una forma mas sencilla de hacerlo?

Ashley Cole / 2010-03-01 20:31:

Disqus is a great tool, I have it on many of my blogs already. It will only get better in the next few years I find Disqus a very good commenting plug-in. You can always check back your comments because Disqus compiles all your entries...so, it's easier to see and follow your comments.

SHina / 2010-03-03 00:11:

Thanks a lot, it's amazing post I like it very much!

Madelena Scott / 2010-03-04 19:58:

DISQUS allows the blogger to have greater control with comments. It's one of the useful tools that any blogger can have

Serine Lawson / 2010-03-04 21:57:

A main reason many people were slow to adapt to a third party commenting system was that comments posted were not ours. Should something happen to the company, all your comments would be gone. Now DISQUS gives you the option to easily import or export comments.

Rachelis Bennette / 2010-03-08 18:27:

Disqus is a great commenting plug-in and I think Disqus is going to be the next best thing in commenting. It's great at stopping spam!...Disqus is Rockssss

Katherine Wagner / 2010-03-10 18:23:

Disqus has always been my favorite commenting system. The speed of it always amazes me.Disqus is under active development.it is a listen to user feedback.

Rebecca Stevens / 2010-03-11 17:12:

I think the most striking feature of DISQUS is how it perform in all the blogs I work on. Pretty fast for a commenting system

Jessalyn Johnson / 2010-03-11 21:43:

Disqus really rocks!! I'm already planning to set it up on my blogs and it is rocks! No blog commenting system can compete with disqus today.

Barbara Marshal / 2010-03-12 22:15:

Disqus Comments is my commenting application of choice. I have just added here and love the ease of integration and the way it looks.


Contents © 2000-2024 Roberto Alsina