#!/usr/bin/env ruby ####################################################################### # referrer_rss.rb - build a RSS feed of site referrers # # by Paul Duncan # ####################################################################### # load technorati bindings require 'technorati' # get URL from command-line, load key URL = ARGV.shift || 'pablotron.org' KEY = IO::readlines(File::join(ENV['HOME'], '.technorati_key')).join.strip # connect to technorati t = Technorati.new(KEY) # run cosmos query for URL results = t.cosmos(URL) # iterate over results and build RSS output of data puts < Technorati: Sites Linking to #{URL} http://technorati.com/ A list of sites linking to #{URL} according to <a href='http://technorati.com/'>Technorati</a>. END_HEADER # iterate over each returned site and print out a link results['items'].each do |item| puts " #{item['weblog/name']} #{item['weblog/url']} #{item['linkcreated']} This site links to #{URL}. #{item['exerpt'] ? 'Exerpt:' << item['exerpt'] : ''} " end # close off RSS feed puts "\n\n"