Created
April 6, 2009 00:58
-
-
Save fauxparse/90588 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby | |
# Find common Twitter friends | |
# Usage: ./twat.rb user1 user2 ... | |
lists = ARGV.inject({}) do |hash, username| | |
page = 1 | |
friends = [] | |
while !(output = `curl -s http://twitter.com/statuses/friends/#{username}.xml?page=#{page} | grep "<screen_name>"`.gsub(%r{</?screen_name>}, '').split).empty? | |
friends += output | |
page += 1 | |
end | |
hash[username] = friends.sort | |
hash | |
end | |
lists.values.inject { |a, b| a & b }.each { |user| puts user } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment