Skip to content

Instantly share code, notes, and snippets.

@ascheink
Created November 12, 2012 22:47
Show Gist options
  • Save ascheink/4062579 to your computer and use it in GitHub Desktop.
Save ascheink/4062579 to your computer and use it in GitHub Desktop.
Election map shares
require 'rubygems'
require 'httparty'
def trackbacks url
response = HTTParty.get "http://otter.topsy.com/trackbacks.json?url=#{url}"
response['response']['trackback_total']
end
def shares url
response = HTTParty.get "https://graph.facebook.com/?ids=#{url}"
response[url]['shares']
end
urls = %w(
http://elections.talkingpointsmemo.com
http://www.cnn.com/election/2012/results/main
http://elections.nytimes.com/2012/results/president
http://elections.msnbc.msn.com/ns/politics/2012/all
http://graphics.latimes.com/2012-election-results-national-map/
http://www.guardian.co.uk/world/us-elections-2012/results/president
http://www.politico.com/2012-election/map/
http://elections.huffingtonpost.com/2012/results
)
urls.each do |url|
puts [trackbacks(url), shares(url), url].join "\t"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment