Created
July 18, 2014 08:49
-
-
Save satococoa/6f65c6427aed3cbfa455 to your computer and use it in GitHub Desktop.
sougo_follow.rb
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
# usage | |
# $ ruby sougo_follow.rb satococoa | |
# follower_ids も friend_ids も rate_limit が厳しいので注意 | |
require 'bundler/setup' | |
Bundler.require | |
screen_name = ARGV[0] | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = '' | |
config.consumer_secret = '' | |
config.access_token = '' | |
config.access_token_secret = '' | |
end | |
redis = Redis.new | |
redis.del 'followers' | |
redis.del 'followings' | |
begin | |
res = client.follower_ids(screen_name) | |
redis.sadd 'followers', res.attrs[:ids] | |
end until res.attrs[:next_cursor_str].to_i == 0 | |
begin | |
res = client.friend_ids(screen_name) | |
redis.sadd 'followings', res.attrs[:ids] | |
end until res.attrs[:next_cursor_str].to_i == 0 | |
sougo_follows = redis.sinter 'followers', 'followings' | |
puts "相互フォロー: #{sougo_follows.count} 人" | |
puts "id: #{sougo_follows.join(', ')}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment