Here is the code we use to generate the list. It uses Amazon's commercial AWIS API -- you must have an account and enter your access keys at the top to run this script!
If you want the 3-month average, use the 19th script block instead of the 17th (line 14)
Updated 3/29/08 - better error handling for sites that drop out of the rankings.
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
require "cgi"
require "base64"
require "openssl"
require "digest/sha1"
require "uri"
require "net/https"
require "xmlsimple"
require "time"
ACCESS_KEY_ID = ""
SECRET_ACCESS_KEY = ""
action = "UrlInfo"
responseGroup = "Rank"
timestamp = ( Time::now ).utc.strftime("%Y-%m-%dT%H:%M:%S.000Z")
signature = Base64.encode64( OpenSSL::HMAC.digest( OpenSSL::Digest::Digest.new( "sha1" ), SECRET_ACCESS_KEY, action + timestamp)).strip
rails100 = Hpricot(open("http://rails100.pbwiki.com/"))
uris = rails100.search("#displaycontent ol li a").collect do |url|
url.attributes["href"]
end.reject {|uri| uri =~ /alexa/}
# uncomment this line to test changes without running up your AWIS bill
# uris = "http://twitter.com", "http://altrulist.org.uk"
top100 = uris.inject({}) do |list, url|
begin
sent = URI.parse("http://awis.amazonaws.com?" +
{
"Action" => action,
"AWSAccessKeyId" => ACCESS_KEY_ID,
"Signature" => signature,
"Timestamp" => timestamp,
"ResponseGroup" => responseGroup,
"Url" => url
}.to_a.collect{|item| item.first + "=" + CGI::escape(item.last) }.join("&") # Put key value pairs into http GET format
)
xml = XmlSimple.xml_in(Net::HTTP.get(sent))
rank = xml["Response"].first["UrlInfoResult"].first["Alexa"].first["TrafficData"].first["Rank"].first.to_i
puts "processed: #{url} [#{rank}]"
list[url.gsub("http://","")] = rank
rescue
puts "error processing: #{url}"
list[url.gsub("http://","")] = "999999999 - no data"
end
list
end.sort_by {|a,b| b.to_i}
top100.each do |url,rank|
puts "# [http://#{url} #{url}] [[http://www.alexa.com/data/details/traffic_details?url=#{url} #{rank}]]"
end
Page Information
|
Wiki Information
|
Recent PBwiki Blog Posts |