Wandering Thoughts archives

2005-09-30

Pinging weblogs.com in Python

In the weblogs world, to 'ping' somewhere is to send an automated notice to an indexing site that your blog has updated. Popular indexing sites include weblogs.com and technorati.com. Major blogging packages already do this out of the box, but if you've rolled your own (such as me, with DWiki) you're on your own.

In a modern blog world with millions of blogs and RSS and Atom syndication feeds, something like weblogs.com looks more than a little bit old fashioned. The reason to still care about this stuff is two words: Google Blogsearch.

To quote from their FAQ:

How do I get my blog listed?

If your blog publishes a site feed in any format and automatically pings an updating service (such as Weblogs.com), we should be able to find and list it. [...]

In other words: until Google manually creates a way to add blogs, pinging weblogs.com and similar sites is the best and possibly the only way to get into their index. Certainly my experience is that WanderingThoughts got much more prompt and up to date indexing in Google Blogsearch after I started pinging places. (I believe that your feed needs to be autodiscoverable from your blog's web page for this to work.)

Mechanically, pings are done through XML-RPC. It turns out that Python's xmlrpclib module makes doing XML-RPC calls very easy, once you understand the magic tricks; they turn into function calls on magic objects. Making it easier, all of the various indexing services use the same XML-RPC procedure call, just to different URLs. (XML-RPC calls have two parts: the actual RPC call, with procedure name and arguments and so on, and the target it's directed at.)

So all you actually need is three lines of code you can find here (which is where I got my start from). To save you the small effort of going there, here's some slightly more general code:

import xmlrpclib
bName = "..."
bUrl = "http://..."

def pingEm(url):
  s = xmlrpclib.Server(url)
  s.weblogUpdates.ping(bName, bUrl)

pingEm("http://rpc.weblogs.com/RPC2")
pingEm("http://rpc.technorati.com/rpc/ping")

Fill in appropriate values for bName and bUrl and you're ready to go.

If you want a list of possible places to ping (and more Python code), here is one list that seems to date from 2004. Other big lists of possible places to ping can be found here, here, or here. Apparently, Ping-O-Matic will ping pretty much everything important for you with just one ping from you (you want 'http://rpc.pingomatic.com/' as the XML-RPC target); they're even sort of recommended by Google.

(Disclaimer: I found these lists by using Google Blogsearch and haven't tried any of the listed ping sites myself. I suggest checking out each one's regular site to see if it looks worthwhile to ping them. And my, there are a lot of blog indexing things.)

python/PingingWeblogsInPython written at 00:53:06; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.