#!/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 '
'+excerpt+'' if nearestpermalink != '': printDeepCosmos(technoratikey, nearestpermalink, levels, seen_query, seen_url, depth) print '
Technorati error: ',errStr,''
if errStr.find('Could not connect to database.') >= 0:
print '
This probably means you did not provide a valid Technorati key or Technorati web services are temprorarily unavailable.'
elif errStr.find('run out') >= 0:
print '
You can find out how many queries you have available here.'
elif errStr.find('Connection timed out') >= 0:
print '
May mean Technorati is having a slow minute. Try again in a few.'
elif errStr.find('Connection refused') >= 0:
print '
May mean Technorati is momentarily unavailable. Try again soon.'
print '
Unexpected error: ',sys.exc_info()[0],'
' if start == 1: 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 '