Created
December 2, 2010 20:37
-
-
Save tommorris/726013 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "nokogiri" | |
require "open-uri" | |
$hash = {} | |
def load_from_api(num) | |
# replace 'blog.tommorris.org' with your tumblr blog URL. | |
data = Nokogiri::XML(open("http://blog.tommorris.org/api/read?num=50&start=#{num}")) | |
tags = data.xpath("//tag").map {|i| i.text } | |
# this initializes the hash key to zero if it isn't already set, then increments | |
tags.each {|i| $hash[i] ||= 0; $hash[i] += 1 } | |
end | |
# replace '108' with the number of posts you have made divided by 50 - rounded up. | |
# your total # of posts is on your dashboard | |
(0..108).to_a.each {|n| | |
load_from_api(n * 50) | |
} | |
fh = File.open(File.expand_path("~/tags.txt"), "w") | |
# reverse sort by value | |
$hash = $hash.sort {|x,y| y[1] <=> x[0] } | |
$hash.each do |line| | |
fh.write("#{line[0]} -- #{line[1].to_s}\n") | |
end | |
fh.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment