Skip to content

Instantly share code, notes, and snippets.

@yswallow
Created October 21, 2012 13:59
Show Gist options
  • Save yswallow/3927039 to your computer and use it in GitHub Desktop.
Save yswallow/3927039 to your computer and use it in GitHub Desktop.
Twitterのクライアントを調べる
# encoding: UTF-8
require 'twitter'
Twitter.configure do |config|
config.consumer_key = 'consumer_key'
config.consumer_secret = 'consumer_secret'
config.oauth_token = 'oauth_token'
config.oauth_token_secret = 'oauth_token_secret'
end
username = ARGV[0] ? ARGV[0].chomp : nil
clients = {}
tweets = Twitter.user_timeline(username)
tweets.each do |tweet|
client = tweet[:source]
client_name = client.gsub(/<.+?>/,"")
if clients[client_name]
clients[client_name] += 1
else
clients[client_name] = 1
end
end
clients.each do |client,count|
puts "#{client}: #{count}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment