#!/usr/local/bin/python # Copyright (C) 2005 Mike Linksvayer # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, # including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. import technorati, sys, cgi, string def printDeepCosmos(technoratikey, url, levels, seen_query={}, seen_url={}, depth=0, start=1): depth = depth + 1 seen_key = str(start)+' '+url if (seen_query.has_key(seen_key)): return else: seen_query[seen_key] = True for ignoreme in IGNORE: if (url == ignoreme): return if start == 1: print '' # list of urls known to lead us down the path of irrelevancy IGNORE = 'http://www.bloglines.com/toplinks', url = '' technoratikey = '' form = cgi.FieldStorage() if form.has_key('url'): url = form['url'].value if form.has_key('technoratikey'): technoratikey = form['technoratikey'].value print """Content-Type: text/html DeepCosmos: Recursive Technorati Query Interface

DeepCosmos: Recursive Technorati Query Interface

URL
Your Technorati Key Remember
[Help]
""" % url if url != '' and technoratikey != '': print """

DeepCosmos for %s

""" % (url, url) levels = {} printDeepCosmos(technoratikey, url, levels) print '

' if len(levels) > 0: print 'Statistics for blogversation starting at %s' % (url, url) print '
Total references: ', levels[0] print '
Direct references: ', levels[1] for level in levels: if level > 1: print "
%d-level references: %s" % (level, levels[level]) else: print 'Sorry, no references found to blogversation starting at %s' % (url, url) print '

' print """
Powered by Technorati · About
"""