ASPN ActiveState Programmer Network  
ActiveState, a division of Sophos
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups
Submit Recipe
My Recipes

All Recipes
All Cookbooks


View by Category

Title: Ping Technocrati with your blog URL
Submitter: Mayuresh Phadke (other recipes)
Last Updated: 2006/10/31
Version no: 1.1
Category: Web

 

Not Rated yet


Description:

Technocrati (http://www.technorati.com/) maintains a list of blogs tagged with user specified tags. People can submit their blogs for inclusion in Technocrati by using their RPC ping service at http://www.technorati.com/ping. This piece of code allows you ping Technocrati with blog details through a script.

Source: Text Source

#!/usr/bin/python
#
# Written by Mayuresh at gmail dot com
#
# This program posts a blog URL to the Technorati ping server

import xmlrpclib
import socket
import sys
from optparse import OptionParser

TECHNORATI_RPC_PING_SERVER = 'http://rpc.technorati.com/rpc/ping'

usage = """ %prog Blog_name Blog_URL

        Example: %prog YourBlogName http://www.YOURWEBLOGURL.com/
        """
parser = OptionParser(usage=usage)
(options, args) = parser.parse_args()

if len(args) != 2:
        parser.error("Invalid options")

print "Submitting the following blog info to %s" % TECHNORATI_RPC_PING_SERVER
print
print "Blog name: %s" % args[0]
print "Blog URL: %s" % args[1]
print
print "Waiting for server response ..."
print

reply = {}

try:
        s = xmlrpclib.Server(TECHNORATI_RPC_PING_SERVER)
        reply = s.weblogUpdates.ping(args[0], args[1])

except socket.error, msg:
        reply['flerror'] = True
        errCode, reply['message'] = msg

except xmlrpclib.ProtocolError, inst:
        reply['flerror'] = True
        reply['message'] = "Error [%s: %s] occured while accesing url %s" %(inst.errcode, inst.errmsg, inst.url)

except xmlrpclib.Fault, inst:
        reply['flerror'] = True
        reply['message'] = inst.faultString

except:
        reply['flerror'] = True
        reply['message'] = "Unknown error occured"

if reply['flerror']:
        print "The server returned an error"
else:
        print "The server returned success"

print
print "Message from the server: %s" % reply['message']

if reply['flerror']:
        sys.exit(1)
else:
        sys.exit()

Discussion:

Getting you blog listed at Technocrati could increase the chances of ppl reading your blog.

Using the script you could set up a cron job to automatically submit your blog to Technocrati on a daily or weekly basis, thus listing your new blog postings on Technocrati.

I have just started programming in Python and become a fan of the language. Just wrote this program to demonstrate how easy it is to write code to perform useful tasks in Python.

Ping-o-matic (http://pingomatic.com/) allows pinging multiple sites with a blog URL. Something similiar to Ping-o-matic could be build by using such scripts.


Note: The author is in no way affiliated with Technocrati and Ping-o-matic.



Add comment

Number of comments: 1

imho, aler saert, 2008/02/25
Very interesting post. I am use this in the work http://www.atakamus.com/music/
Add comment



Highest rated recipes:

1. A simple XML-RPC server

2. Web service accessible ...

3. a friendly mkdir()

4. SOLVING THE METACLASS ...

5. Povray for python

6. Changing return value ...

7. Implementation of sets ...

8. bag collection class

9. deque collection class

10. Floating Point Simulator




Privacy Policy | Email Opt-out | Feedback | Syndication
© 2006 ActiveState Software Inc. All rights reserved.