Ping Technorati from your Django blog using xml-rpc

Ping Technorati from your Django blog using xml-rpc

A very simple way of pinging Technorati every time you update your blog using the xmlrpclib in python. Also an example of pinging Google blog search.

Technorati is a blog search engine, they have an xml-rpc server that lets you ping them with your blog name and address, Technorati will then re-index your blog.

A simple way to do this is to use the python xmlrpclib, which is a default module in python.

First thing to do is import the module, so include this in your blog post's models.py file:

import xmlrpclib

then add this to your blog post model class:

def save(self):
    j = xmlrpclib.Server('http://rpc.technorati.com/rpc/ping')
    reply = j.weblogUpdates.ping('Your Blog Name','http://www.yourblog.com')
    super(Entry,self).save() #change "Entry" to the name of your blog posts model name

Now every time you save a new blog post django will ping the Technorati server with your site.

The example below will ping Google blog search as well, although because Google requires the url of the post it requires some xtra parameters. I have a function in my blog post model called get_absolute_url, this returns the exact url of the post:

def get_absolute_url(self):
    return "/blog/%s/%s/" % (self.pub_date.strftime("%Y/%b/%d").lower(), self.slug)

def save(self):
    blogUrl = 'http://www.yourblog.com'
    postUrl = blogUrl+self.get_absolute_url()
    feedUrl = 'http://www.yourblog.com/feeds/latest/'
    # Ping Technorati
    j = xmlrpclib.Server('http://rpc.technorati.com/rpc/ping')
    reply = j.weblogUpdates.ping('Blog Name',blogUrl)
    # Ping Google Blog Search
    j = xmlrpclib.Server('http://blogsearch.google.com/ping/RPC2')
    reply = j.weblogUpdates.ping('Blog Name',blogUrl,postUrl)
    super(Entry,self).save()

Posted on April 21, 2007
Tags: Django, Python

Comments

1

everes commented, on May 13, 2007 at 1:41 p.m.:

I think you should save before pinging.

2

Adam commented, on May 14, 2007 at 11:17 a.m.:

Yes you're probably right. Would be better as well to move this all into another python script and just send it the page url.

3

Christian Jørgensen commented, on August 18, 2007 at 9:42 a.m.:

Or activate it using signals.

4

Thomas commented, on January 15, 2009 at 7:41 p.m.:

Thanks for the info, works great. I had been using www.BlogBuzzer.com for awhile to automatically ping.

5

Gavin D commented, on February 22, 2009 at 2:22 a.m.:

Similar you can ping at http://pingablog.ezedir.com/

Gavin

Post a comment

Your name:

Comment: